Skip to content

cennznet/contract-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contract Template

A minimal contract intended as a template for new projects.

> tree
.
├── Cargo.toml
├── README.md
├── build.sh
└── src
    └── lib.rs

Usage

# Setup `cargo generate` command
cargo install cargo-generate

# Create a new project from this template
cargo generate --git https://github.com/cennznet/contract-template --name my-new-contract

Build

./build.sh 
# outputs:
# - wasm binary: `./target/my-new-contract.wasm`
# - JSON ABI:    `./target/my-new-contract.json`

Deploy

install @cennznet/cli if not.

# sync latest scripts
$ cennz-cli script:update

$ cennz-cli script:run [OPTIONS] contract-deploy PATH_TO_WASM ACCOUNT

OPTIONS
  -c, --endpoint=endpoint  [default: ws://localhost:9944] cennznet node endpoint
  -f, --path=path          [default: /Users/moge/.cennz_cli/wallet.json] path to wallet.json
  -p, --passphrase         if a passphrase is needed
  --noApi                  pass true if the script doesn't need to connect to the network

# outputs:
# contract code hash: 0x...
# ExtrinsicSuccess

Calculate code hash off-chain

$ cennz-cli script:run --noApi contract-hashcode PATH_TO_WASM

Instantiate

# sync latest scripts
$ cennz-cli script:update

$ cennz-cli script:run [OPTIONS] contract-instantiate ACCOUND_ID CODE_HASH PATH_TO_ABI ENDOWMENT GAS_LIMIT

OPTIONS
  -c, --endpoint=endpoint  [default: ws://localhost:9944] cennznet node endpoint
  -f, --path=path          [default: /Users/moge/.cennz_cli/wallet.json] path to wallet.json
  -p, --passphrase         if a passphrase is needed
  --noApi                  pass true if the script doesn't need to connect to the network

# outputs:
# contract addr: 5H39JxdvKhUPyV7p48gFzSsCSMVnZfXZmhsfgHy6AjpMFyUw
# or ExtrinsicFail

Calculate contract address off-chain

$ cennz-cli script:run --noApi contract-addr OWNER_ACCOUNT CODE_HASH PATH_TO_ABI

About

A CENNZNet smart contract template

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •