You can always find the newest documentation on the main site.
To develop and compile contracts for the Partisia Blockchain, you need to install Rust. To install Rust for you platform follow the instructions on https://rustup.rs/.
The newest version of Rust comes with a wasm target preinstalled. If you run an older version the target needs to be added manually, by running:
rustup target add wasm32-unknown-unknown
To compile contracts you will also need to install Git.
If you need to develop zero-knowledge contracts then you will also need to install Java 17 to run the zk-compiler.
If Working from a Windows machine you must get Visual Studio with C++ build tools
- In Visual Studio Installer choose Desktop development with C++.
The partisia-contract tool is a small application that helps you compile a contract. To compile it and install it using cargo run:
cargo install cargo-partisia-contract
Test that it worked by executing: cargo partisia-contract --version
. This should print the version of the tool.
To compile a contract you simply change directory to one of the rust-example-contracts and compile:
cd ..
cd contracts/token/
cargo partisia-contract build --release
The --release
flag compiles the contract in release mode and can be excluded to only test the compilation of the contract.
The zk-contracts consist of two main parts. The contract itself as well as a zero-knowledge computation. The partisia-contract tool is able to detect and compile both these parts together. To do so the tool fetches the zk-compiler.jar and runs it.
cd ..
cd contracts/example-zk-voting/
cargo partisia-contract build --release
This creates the linked byte file with the zk wasm file (.zkwa) as well as the wasm file.
There are contracts included in the zip as well as zero knowledge contracts.
The included normal contracts are:
- An ERC20 token contract located in
contracts/token
- A general purpose voting contract located in
contracts/voting
- An auction contract that sells ERC20 tokens of one type for another located in
contracts/auction
- An NFT contract located in
contracts/nft
- An escrow contract that transfers tokens when a condition is met, located in
contract/conditional-escrow-transfer
- A liquidity swap contract that exchanges one type of tokens for another, located in
contract/liquidity-swap
- A contract that deploys voting contracts located in
contracts/multi-voting
The included zk-contracts are:
- A secret voting contract located in
contracts/zk-voting
- An average salary contract located in
contracts/zk-average-salary
- A second price auction contract located in
contracts/zk-second-price-auction
Multiple of the examples are described in great detail on the main site.
For writing your own contract refer to the documentation on the main site.# partisia-example-contracts