README.md
October 21, 2021 ยท View on GitHub
Intro
This repo is a simple Substrate style wasm smart contract for a secret registry.
Install Node.js
please reference to Node.js Website
-
We recommend you to install yarn as an alternative to
npm. Simple runnpm install --global yarn -
The repo is tested with nodejs version
14.6.0, to check on your nodejs versionnode -v, to switch version of node, I recommend using n by TJ.
Setup the Substrate smart contract development environment
A good general guide to setup the environment for Substrate environment can be founded here.
-
Install Rust for help: refer to Rust Website
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/envCheck your installed version
rustc --version cargo --versionThis guides is tested with
rustc 1.50.0 (cb75ad5db 2021-02-10)andcargo 1.50.0 (f04e7fab7 2021-02-04) -
Install Binaryen. You can simply install with Homebrew on macOS
brew install binaryenTo install
Homebrewuse/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -
Install cargo-contract
cargo install --force cargo-contract -
Grab a local Substrate blockchain node with
pallet-contractincluded. There are many options: jupiter is the one we choose. Alternatively, you can get canvas by Parity.Rustis known for compiling slowly. It took me an hour to compile jupiter.-
Lastly, fire up the local blockchain
path-to-jupiter-repo/target/release/jupiter-prep --dev # OR with Canvas canvas --dev --tmpYou can visit https://ipfs.io/ipns/dotapps.io and choose to connect to
ws://127.0.0.1:9944to have a visual portal to interact with the blockchain.
My Environment
Codes are tested with the following environment:
binaryen: version 101
cargo: cargo 1.55.0 (32da73ab1 2021-08-23)
cargo-contract: cargo-contract 0.10.0
node: v14.16.0
rust: rustc 1.51.0 (2fd73fabe 2021-03-23)
canvas: canvas 0.1.0-25fd60f-x86_64-linux-gnu
OS Version: macOS Big Sur 11.0.1
ts-node: v10.0.0
mocha: 8.4.0
Node Packages
Please refer to the package.json
Run Test
- Clone this repo to your local environment & install dependencies
git clone git@github.com:skyekiwi/contract-demo.git
yarn
- (Optional) Create
.envfiles at the project home directory and write your seed phrase to it. Inject a seed phrase only if you want to deploy the contract.
SEED_PHRASE = 'xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx'
- Run Tests. The process can take somewhere between 3minutes to 10 minutes, depends on network connection.
yarn test
- Relax. The test should be able to finish within 10 minutes.
LICENSE
Apache 2.0. See the LICNESE File.
Contact
Email: hello@skye.kiwi
Telegram: @songzhou26