Rust Engineer

Antonio

yanganto@Github

2021/11/12 Hackthon @OnAir

Utility Token   

with SewUp

Hackathon

Intro

SewUp

  • Rust crate
  • Open source at Github
  • Utilize Ethereum WebAssembly
  • Contract Dev as Backend (CDAB)
  • Rusty api
  • Learn more with previous slides

Token Feature

Token Feature

Let's SewUp

Your ERC-20 in 5min

  1. Copy the ERC-20 example of Sewup project
  2. Modify name, symbol, total_supply...
  3. Complete `sewup.toml`
  4. Deploy by `cargo sewup`

Your ERC-20 in 5min

Your ERC-20 in 5min

Just `cargo sewup`

You create a your own ERC-20 token

And More

Utility Token

  • Token for some product or service
  • Sample code
  • Use Sewup token feature

Rules

  1. Admin can check the balance of any user
  2. Admin can charge the balance for any user
  3. User can check the remaining balance of heself
  4. User can spend some his balance to others
  5. Admin can reduce the balance of a user

Init project

  1. Install Rust
    curl --proto '=https' --tlsv1.2 -sSf \ https://sh.rustup.rs | sh
  2. Install cargo sewup
    cargo install cargo-sewup
  3. Initialize project
    cargo sewup init
  4. Add kv feature
    features = [ "token" ]

Check out Commit 14cbef0

How to debug

  1. Use cargo test to validate you code
  2. If _compile_runtime_test fail,
    run cargo build --target=wasm32-unknown-unknown
  3. If _compile_constructor_test fail,
    run cargo build --features=constructor --target=wasm32-unknown-unknown

Tips for development

Reuse API from ERC20

Check out Commit 9bdb4ac

Objective

  1. Use mint to setup default tokens
  2. Reuse transfer, balance_of
  3. Setup test case

Balance_of Wrapper

Check out Commit 0919bae

Objective

  1. Reuse  ERC-20 standard balance_of
  2. Add access control for balance_of
  3. Setup test case

Mint for admin

Check out Commit 6d15642

Objective

  1. Admin can mint for his self
  2. Admin can transfer to other user (Origin ERC-20)
  3. Admin can charge balance for other user

Reduce user balance

Check out Commit e203731

Objective

  1. Admin can reduce the balance of user

Well Done

Hack with SewUp

It's Your Turn

Refactor Caller Validation

Deploy & Test Rule 5

  • Add Rule 5 abi to utils.js of web3
  • Deploy contract on testnet
  • Modify token.js script

Summary

Blockchain bring TRUST to the world

Rust is the stem of TRUST

SewUp base on Rust and Ewasm helps you build great blockchain applications

Thanks for listening

Star the project if you like it

There are also help want issues and good first issues

Interested in VM?

WasmEdge is welcom to contribute

Q&A

Sewup sew your ethereum project up to the world

Made with Slides.com