This repo is a simple Substrate style wasm smart contract for a secret registry.
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.
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/env
Check your installed version
rustc --version cargo --version
This 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 binaryen
To install
Homebrew
use/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-contract
included. There are many options: jupiter is the one we choose. Alternatively, you can get canvas by Parity.Rust
is 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 --tmp
You can visit https://ipfs.io/ipns/dotapps.io and choose to connect to
ws://127.0.0.1:9944
to have a visual portal to interact with the blockchain.
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
- Clone this repo to your local environment & install dependencies
git clone git@github.com:skyekiwi/contract-demo.git
yarn
- (Optional) Create
.env
files 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.
Apache 2.0. See the LICNESE
File.
Email: hello@skye.kiwi
Telegram: @songzhou26