Key Value Storage
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
Key Value Storage
Let's SewUp
Hangman
Rules
- Every account can set only a word as the puzzle, a sentence as the reward for people solve the puzzle, and a hint for people
- Everyone can get the information of the puzzle (the length of words and the hint).
- Everyone guess one char, for example p, and he will get a partial string like -pp--.
- Everyone can guess the word, if correct, he will see the sentence.
Init project
- Install Rust
curl --proto '=https' --tlsv1.2 -sSf \ https://sh.rustup.rs | sh
- Install cargo sewup
cargo install cargo-sewup
- Initialize project
cargo sewup init -m rusty
- Add kv feature
features = [ "kv" ]
Setup constructor
Check out Commit 52832e4
Objective
- Define datastructure
- Initialize storage when deploy
- Every account can set only a word as the puzzle, a sentence as the reward for people solve the puzzle, and a hint for people
Setup constructor
Check out Commit 52832e4
- Use cargo test to validate you code
- If _compile_runtime_test fail,
run cargo build --target=wasm32-unknown-unknown - If _compile_constructor_test fail,
run cargo build --features=constructor --target=wasm32-unknown-unknown
Tips for developing constructor
Setup Puzzle
Check out Commit 11bf360
Objective
- Handle the data from client ewasm_input_from!
- Storage data on chain, commit
- Test with specific caller, by
Get Puzzle Info
Objective
- Use EwasmAny for return different
- Initial Input structure, just like form in HTTP
Guess Char
Objective
- Modify the Input structure
- Initial Input structure, just like form in HTTP
- Update testcase
Guess Word
Objective
- Modify the Input structure
- Initial Input structure, just like form in HTTP
- Update testcase
Well Done
Really Easy with SewUp
It's Your Turn
Validate Puzzle
Introduce thiserror
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
Writing Ethereum WebAssembly in Rust II - Key Value Storage with SewUp
By Antonio Yang
Writing Ethereum WebAssembly in Rust II - Key Value Storage with SewUp
Secondstate EWasm Utility Program, a library to help you to write Ethereum WebAssmbly in Rust
- 1,296