{"id":19824559,"url":"https://github.com/tetcoin/pro","last_synced_at":"2025-10-03T17:32:04.524Z","repository":{"id":42471633,"uuid":"334333817","full_name":"tetcoin/pro","owner":"tetcoin","description":"Tetsy pro! for writing smart contracts","archived":false,"fork":false,"pushed_at":"2022-12-02T10:03:16.000Z","size":78628,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-02T14:19:17.164Z","etag":null,"topics":["cryptocurrency","programming","smart-contracts"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tetcoin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.adoc","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-30T05:14:41.000Z","updated_at":"2021-10-24T08:52:56.000Z","dependencies_parsed_at":"2023-01-23T07:45:37.621Z","dependency_job_id":null,"html_url":"https://github.com/tetcoin/pro","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetcoin%2Fpro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetcoin%2Fpro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetcoin%2Fpro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetcoin%2Fpro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tetcoin","download_url":"https://codeload.github.com/tetcoin/pro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233460994,"owners_count":18679771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptocurrency","programming","smart-contracts"],"created_at":"2024-11-12T11:04:31.611Z","updated_at":"2025-09-18T08:30:56.346Z","avatar_url":"https://github.com/tetcoin.png","language":"Rust","readme":"\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"./.images/pro-logo-glow.svg\" alt=\"pro!\" height=\"136\" /\u003e\n\u003ch1 align=\"center\"\u003e\n    Tetsy pro! for writing smart contracts\n\u003c/h1\u003e\n\n[![codecov][c1]][c2] [![coveralls][d1]][d2] [![loc][e1]][e2] [![matrix][k1]][k2] [![discord][l1]][l2]\n\n[a1]: https://gitlab.tetcoin.org/tetcoin/pro/badges/master/pipeline.svg\n[a2]: https://gitlab.tetcoin.org/tetcoin/pro/pipelines?ref=master\n[c1]: https://codecov.io/gh/tetcoin/pro/branch/master/graph/badge.svg\n[c2]: https://codecov.io/gh/tetcoin/pro/branch/master\n[d1]: https://coveralls.io/repos/github/tetcoin/pro/badge.svg?branch=master\n[d2]: https://coveralls.io/github/tetcoin/pro?branch=master\n[e1]: https://tokei.rs/b1/github/tetcoin/pro?category=code\n[e2]: https://github.com/Aaronepower/tokei#badges\n[f1]: https://img.shields.io/badge/click-blue.svg\n[f2]: https://tetcoin.github.io/pro/pro_storage\n[g1]: https://img.shields.io/badge/click-blue.svg\n[g2]: https://tetcoin.github.io/pro/pro_env\n[i1]: https://img.shields.io/badge/click-blue.svg\n[i2]: https://tetcoin.github.io/pro/pro_prelude\n[j1]: https://img.shields.io/badge/click-blue.svg\n[j2]: https://tetcoin.github.io/pro/pro_lang\n[k1]: https://img.shields.io/badge/matrix-chat-brightgreen.svg?style=flat\n[k2]: https://riot.im/app/#/room/#pro:matrix.tetcoin.org\n[l1]: https://img.shields.io/discord/722223075629727774?style=flat-square\u0026label=discord\n[l2]: https://discord.gg/ztCASQE\n\n\u003e 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 [Tetcore](https://github.com/tetcoin/tetcore) framework.\n\n\u003cbr/\u003e\n\n[Guided Tutorial for Beginners](https://substrate.dev/substrate-contracts-workshop/#/0/building-your-contract) •\n[pro! Documentation Portal](https://tetcoin.github.io/pro-docs)\n\n\u003cbr/\u003e\n\u003c/div\u003e\n\nMore relevant lpros:\n* Talk to us on [Element][k2] or [Discord][l2]\n* [`cargo-contract`](https://github.com/tetcoin/cargo-contract) ‒ cli tool for pro! contracts\n* [Canvas UI](https://tetcoin.github.io/canvas-ui/#/upload) ‒ webpage for contract deployment and interaction\n\n## Table of Contents\n\n* [Play with It](#play-with-it)\n* [Usage](#usage)\n* [Hello, World! ‒ The Flipper](#hello-world--the-flipper)\n* [Examples](#examples)\n* [How it Works](#how-it-works)\n* [pro! Macros \u0026 Attributes Overview](#pro-macros--attributes-overview)\n  * [Entry Point](#entry-point)\n  * [Trait Definitions](#trait-definitions)\n  * [Off-chain Testing](#off-chain-testing)\n* [Developer Documentation](#developer-documentation)\n* [Contributing](#contributing)\n* [License](#license)\n\n\n## Play with It\n\nWe have [a demonstration testnet](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fcanvas-rpc.tetcoin.org) running.\nYou 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).\n\nThe [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.\nIf you want a quickstart you can use our [canvas-node](https://github.com/tetcoin/canvas-node#note) project.\nIt'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).\n\n## Usage\n\nA 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).\n\nWe 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!:\n\n```\ncargo install cargo-contract --force\n```\n\nUse the `--force` to ensure you are updated to the most recent `cargo-contract` version.\n\nIn order to initialize a new pro! project you can use:\n\n```\ncargo contract new flipper\n```\n\nThis will create a folder `flipper` in your work directory.\nThe folder contains a scaffold `Cargo.toml` and a `lib.rs`, which both contain the necessary building blocks for using pro!.\n\nThe `lib.rs` contains our hello world contract ‒ the `Flipper`, which we explain in the next section.\n\nIn order to build the contract just execute these commands in the `flipper` folder:\n```\ncargo contract build\n```\n\nAs a result you'll get a file `target/flipper.wasm` file, a `metadata.json` file and a `\u003ccontract-name\u003e.contract` file in the `target` folder of your contract.\nThe `.contract` file combines the Wasm and metadata into one file and needs to be used when deploying the contract.\n\n\n## Hello, World! ‒ The Flipper\n\nThe `Flipper` contract is a simple contract containing only a single `bool` value.\nIt provides methods to\n* flip its value from `true` to `false` (and vice versa) and\n* return the current state.\n\n\nBelow you can see the code using the `pro_lang` version of pro!.\n\n```rust\nuse pro_lang as pro;\n\n#[pro::contract]\nmod flipper {\n    /// The storage of the flipper contract.\n    #[pro(storage)]\n    pub struct Flipper {\n        /// The single `bool` value.\n        value: bool,\n    }\n\n    impl Flipper {\n        /// Instantiates a new Flipper contract and initializes `value` to `init_value`.\n        #[pro(constructor)]\n        pub fn new(init_value: bool) -\u003e Self {\n            Self {\n                value: init_value,\n            }\n        }\n\n        /// Flips `value` from `true` to `false` or vice versa.\n        #[pro(message)]\n        pub fn flip(\u0026mut self) {\n            self.value = !self.value;\n        }\n\n        /// Returns the current state of `value`.\n        #[pro(message)]\n        pub fn get(\u0026self) -\u003e bool {\n            self.value\n        }\n    }\n\n    /// Simply execute `cargo test` in order to test your contract using the below unit tests.\n    #[cfg(test)]\n    mod tests {\n        use super::*;\n\n        #[test]\n        fn it_works() {\n            let mut flipper = Flipper::new(false);\n            assert_eq!(flipper.get(), false);\n            flipper.flip();\n            assert_eq!(flipper.get(), true);\n        }\n    }\n}\n```\n\nPlace this code in the `./lib.rs` file of your flipper contract and run `cargo contract build` to build your first pro! smart contract example.\n\n## Examples\n\nIn the `examples` folder you'll find a number of examples written in pro!.\n\nSome of the most interesting ones:\n\n* `delegator` ‒ Implements cross-contract calling.\n* `trait-erc20` ‒ Defines a trait for `Erc20` contracts and implements it.\n* `erc721` ‒ An exemplary implementation of `Erc721` NFT tokens.\n* `dns` ‒  A simple `DomainNameService` smart contract.\n* …and more, just rummage through the folder 🙃.\n\nTo build a single example navigate to the root of the example and run:\n```\ncargo contract build\n```\n\nYou should now have an optimized `\u003ccontract-name\u003e.wasm` file and a `metadata.json` file in the `target` folder of the contract.\n\nFor further information, please have a look at the [Play with It](#play-with-it) section or our [smart contracts workshop](https://substrate.dev/substrate-contracts-workshop/).\n\n\n## How it Works\n\n* Substrate's [Framework for Runtime Aggregation of Modularised Entities (FRAME)](https://substrate.dev/docs/en/next/conceptual/runtime/frame) contains\na module  which implements an API for typical functions smart contracts need (storage, querying information about accounts, …).\nThis module is called the `contracts` pallet,\n* The `contracts` pallet requires smart contracts to be uploaded to the blockchain as a Wasm blob.\n* pro! is a smart contract language which targets the API exposed by `contracts`.\nHence pro! contracts are compiled to Wasm.\n* When executing `cargo contract build` an additional file `metadata.json` is created.\nIt contains information about e.g. what methods the contract provides for others to call.\n\n## pro! Macros \u0026 Attributes Overview\n\n### Entry Point\n\nIn a module annotated with `#[pro::contract]` these attributes are available:\n\n| Attribute | Where Applicable | Description |\n|:--|:--|:--|\n| `#[pro(storage)]` | On `struct` definitions. | Defines the pro! storage struct. There can only be one pro! storage definition per contract. |\n| `#[pro(event)]` | On `struct` definitions. | Defines an pro! event. A contract can define multiple such pro! events. |\n| `#[pro(anonymous)]` | Applicable to pro! events. | Tells the pro! codegen to treat the pro! event as anonymous which omits the event signature as topic upon emitting. Very similar to anonymous events in Solidity. |\n| `#[pro(topic)]` | Applicate on pro! event field. | Tells the pro! codegen to provide a topic hash for the given field. Every pro! event can only have a limited number of such topic field. Similar semantics as to indexed event arguments in Solidity. |\n| `#[pro(message)]` | Applicable to methods. | Flags a method for the pro! storage struct as message making it available to the API for calling the contract. |\n| `#[pro(constructor)]` | Applicable to method. | Flags a method for the pro! storage struct as constructor making it available to the API for instantiating the contract. |\n| `#[pro(payable)]` | Applicable to pro! messages. | Allows receiving value as part of the call of the pro! message. pro! constructors are implicitly payable. |\n| `#[pro(selector = \"..\")]` | Applicable to pro! messages and pro! constructors. | Specifies a concrete dispatch selector for the flagged entity. This allows a contract author to precisely control the selectors of their APIs making it possible to rename their API without breakage. |\n| `#[pro(namespace = \"..\")]` | Applicable to pro! trait implementation blocks. | Changes the resulting selectors of all the pro! messages and pro! constructors within the trait implementation. Allows to disambiguate between trait implementations with overlapping message or constructor names. Use only with great care and consideration! |\n| `#[pro(impl)]` | Applicable to pro! implementation blocks. | Tells the pro! codegen that some implementation block shall be granted access to pro! internals even without it containing any pro! messages or pro! constructors. |\n\nSee [here](https://tetcoin.github.io/pro/pro_lang/attr.contract.html) for a more detailed description of those and also for details on the `#[pro::contract]` macro.\n\n### Trait Definitions\n\nUse`#[pro::trait_definition]` to define your very own trait definitions that are then implementable by pro! smart contracts.\nSee e.g. the [`examples/trait-erc20`](https://github.com/tetcoin/pro/blob/master/examples/trait-erc20/lib.rs#L49-L51) contract on how to utilize it or [the documentation](https://tetcoin.github.io/pro/pro_lang/attr.trait_definition.html) for details.\n\n### Off-chain Testing\n\nThe `#[pro::test]` proc. macro enables off-chain testing. See e.g. the [`examples/erc20`](https://github.com/tetcoin/pro/blob/master/examples/erc20/lib.rs#L278-L280) contract on how to utilize those or [the documentation](https://tetcoin.github.io/pro/pro_lang/attr.test.html) for details.\n\n## Developer Documentation\n\nWe have [a very comprehensive documentation portal](https://tetcoin.github.io/pro-docs),\nbut if you are looking for the crate level documentation itself, then these are\nthe relevant lpros:\n\n| Crate | Docs | Description |\n|:--|:--|:--|\n`pro_lang` | [![][j1]][j2] | Language features expose by pro!. See [here](https://tetcoin.github.io/pro/pro_lang/attr.contract.html) for a detailed description of attributes which you can use in an `#[pro::contract]`. |\n`pro_storage` | [![][f1]][f2] | Data structures available in pro!. |\n`pro_env` | [![][g1]][g2] | Low-level interface for interacting with the smart contract Wasm executor. |\n`pro_prelude` | [![][i1]][i2] | Common API for no_std and std to access alloc crate types. |\n\n\n## Contributing\n\nVisit our [contribution guidelines](CONTRIBUTING.md) for more information.\n\nUse the scripts provided under `scripts/check-*` directory in order to run checks on either the workspace or all examples. Please do this before pushing work in a PR.\n\n## License\n\nThe entire code within this repository is licensed under the [Apache License 2.0](LICENSE). Please [contact us](https://tetcoin.org/contact/) if you have questions about the licensing of our products.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftetcoin%2Fpro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftetcoin%2Fpro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftetcoin%2Fpro/lists"}