Tetsy pro! for writing smart contracts
[![codecov][c1]][c2] [![coveralls][d1]][d2] [![loc][e1]][e2] [![matrix][k1]][k2] [![discord][l1]][l2]
[a1]: https://gitlab.tetcoin.org/tetcoin/pro/badges/master/pipeline.svg
[a2]: https://gitlab.tetcoin.org/tetcoin/pro/pipelines?ref=master
[c1]: https://codecov.io/gh/tetcoin/pro/branch/master/graph/badge.svg
[c2]: https://codecov.io/gh/tetcoin/pro/branch/master
[d1]: https://coveralls.io/repos/github/tetcoin/pro/badge.svg?branch=master
[d2]: https://coveralls.io/github/tetcoin/pro?branch=master
[e1]: https://tokei.rs/b1/github/tetcoin/pro?category=code
[e2]: https://github.com/Aaronepower/tokei#badges
[f1]: https://img.shields.io/badge/click-blue.svg
[f2]: https://tetcoin.github.io/pro/pro_storage
[g1]: https://img.shields.io/badge/click-blue.svg
[g2]: https://tetcoin.github.io/pro/pro_env
[i1]: https://img.shields.io/badge/click-blue.svg
[i2]: https://tetcoin.github.io/pro/pro_prelude
[j1]: https://img.shields.io/badge/click-blue.svg
[j2]: https://tetcoin.github.io/pro/pro_lang
[k1]: https://img.shields.io/badge/matrix-chat-brightgreen.svg?style=flat
[k2]: https://riot.im/app/#/room/#pro:matrix.tetcoin.org
[l1]: https://img.shields.io/discord/722223075629727774?style=flat-square&label=discord
[l2]: https://discord.gg/ztCASQE
>
pro! is an [eDSL](https://wiki.haskell.org/Embedded_domain_specific_language) to write WebAssembly based smart contracts using the Rust programming language. The compilation target are blockchains built on the [Substrate](https://github.com/tetcoin/substrate) framework.
[Guided Tutorial for Beginners](https://substrate.dev/substrate-contracts-workshop/#/0/building-your-contract) •
[pro! Documentation Portal](https://tetcoin.github.io/pro-docs)
More relevant lpros:
* Talk to us on [Element][k2] or [Discord][l2]
* [`cargo-contract`](https://github.com/tetcoin/cargo-contract) ‒ cli tool for pro! contracts
* [Canvas UI](https://tetcoin.github.io/canvas-ui/#/upload) ‒ webpage for contract deployment and interaction
## Table of Contents
* [Play with It](#play-with-it)
* [Usage](#usage)
* [Hello, World! ‒ The Flipper](#hello-world--the-flipper)
* [Examples](#examples)
* [How it Works](#how-it-works)
* [pro! Macros & Attributes Overview](#pro-macros--attributes-overview)
* [Entry Point](#entry-point)
* [Trait Definitions](#trait-definitions)
* [Off-chain Testing](#off-chain-testing)
* [Developer Documentation](#developer-documentation)
* [Contributing](#contributing)
* [License](#license)
## Play with It
We have [a demonstration testnet](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fcanvas-rpc.tetcoin.org) running.
You can request some tokens to play with from our [Faucet](https://riot.im/app/#/room/#canvas_faucet:matrix.tetcoin.org) and deploy your contracts via the [Canvas UI](https://tetcoin.github.io/canvas-ui/#/upload).
The [Canvas UI](https://tetcoin.github.io/canvas-ui/#/upload) can also be used to deploy your contract to e.g. a Substrate chain which you run locally and execute calls there.
If you want a quickstart you can use our [canvas-node](https://github.com/tetcoin/canvas-node#note) project.
It's a simple Substrate blockchain which is configured to include the Substrate module for smart contract functionality ‒ the `contracts` pallet (see [How it Works](#how-it-works) for more).
## Usage
A prerequisite for compiling smart contracts is to have Rust and Cargo installed. Here's [an installation guide](https://doc.rust-lang.org/cargo/getting-started/installation.html).
We recommend installing [`cargo-contract`](https://github.com/tetcoin/cargo-contract), a CLI tool for helping setting up and managing WebAssembly smart contracts written with pro!:
```
cargo install cargo-contract --force
```
Use the `--force` to ensure you are updated to the most recent `cargo-contract` version.
In order to initialize a new pro! project you can use:
```
cargo contract new flipper
```
This will create a folder `flipper` in your work directory.
The folder contains a scaffold `Cargo.toml` and a `lib.rs`, which both contain the necessary building blocks for using pro!.
The `lib.rs` contains our hello world contract ‒ the `Flipper`, which we explain in the next section.
In order to build the contract just execute these commands in the `flipper` folder:
```
cargo contract build
```
As a result you'll get a file `target/flipper.wasm` file, a `metadata.json` file and a `