Skip to content

Astrapolis-peasant/sub0_erc20_pausable

Repository files navigation

WASM Smart Contract With Patract Labs

Patract Labs

Slides and transcripts

Documents

  • Redspot: Contract Dev Scaffold
  • Europa: Contract Sandbox Env
  • Metis: Standard Contract Library

Demo Setup

Making sure you have cargo-contract setup: Please follow the guide on ink! to setup rust, cargo and cargo-contracts

Making sure you have npx installed

  1. Start your first Redspot Project using Redspot templates:
npx redspot-new erc20

remember to change the dependencies in cargo.toml to pull from crate.io, otherwise it will have compatible issues with polkadot.js

ink_primitives = { version = "3.0.0-rc5", default-features = false }
ink_metadata = { version = "3.0.0-rc5", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "3.0.0-rc5", default-features = false }
ink_storage = { version = "3.0.0-rc5", default-features = false }
ink_lang = { version = "3.0.0-rc5", default-features = false }
  1. Download Europa-UI

Detailed release information can be found here Release v0.3.32. Currently, 3 operating systems are supportd:

For ubuntu, remember to give it permission chmod +x europa-ui-v0.3.32-x86_64-linux.AppImage

  1. Start Europa-UI
  • Simply double click the icon to start it. Making sure the default port is not occupied.

  • Click start to start the node.

  1. Test Redspot + Europa using templated contract and config
npx redspot run scripts/deploy.ts

It will compile the contracts and update contract + metadata to Europa-UI. If the metadata does not get uploaded correctly, you can manual add that.

  • open Europa-UI, you should be able to see the contract has been successfully deployed.
  • you can use back to Block to revert the blockchain and remove the deployed test contract
  1. Copy dependency in Cargo.toml and contract code in lib.rs into erc20/contracts/Cargo.toml and erc20/contracts/lib.rs

  2. Build your contract with

cd contracts
cargo +nightly contract build --keep-debug-symbols --optimization-passes=0

then copy it to artifacts dir under erc20 directory

this will build the contract in debug mode and keeps all debug symbols.

mkdir ../artifacts
cp ./target/ink/erc20_pausable.contract ../artifacts/
cp ./target/ink/metadata.json ../artifacts/erc20_pausable.json 
  1. write the deployment script.

    • copy the code from deploy.ts
    • npx redspot run scripts/deploy.ts --no-compile
    • open Europa-UI to check if the contract has been successfully deployed
  2. Writing tests:

    • copy all the code from tests
    • npx redspot test ./tests/erc20_pausable_init.test.ts --no-compile
    • npx redspot test ./tests/erc20_pausable_ownable.test.ts --no-compile
    • npx redspot test ./tests/erc20_pausable_pause.test.ts --no-compile

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published