Skip to content

skyekiwi/contract-demo

Repository files navigation

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 run npm install --global yarn

  • The repo is tested with nodejs version 14.6.0 , to check on your nodejs version node -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.

  1. 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) and cargo 1.50.0 (f04e7fab7 2021-02-04)

  2. 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)"
  3. Install cargo-contract

    cargo install --force cargo-contract
  4. 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.

    • To use jupiter, follow this guide.

    • To use canvas, follow this guide.

    • 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.

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

  1. Clone this repo to your local environment & install dependencies
git clone git@github.com:skyekiwi/contract-demo.git
yarn
  1. (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'
  1. Run Tests. The process can take somewhere between 3minutes to 10 minutes, depends on network connection.
yarn test
  1. 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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published