A guide to WASM(ink!) implementation for beginners

Summary

Motivation

Table Of Contents

Environment

How to create a project

cargo contract new sample_project

What you need to know to implement basic smart contracts

Basic knowledge

https://github.com/realtakahashi/polkadot_js_examples
https://github.com/realtakahashi/polkadot_js_examples
https://github.com/realtakahashi/polkadot_js_examples
https://github.com/realtakahashi/dao4commons.wasm/blob/main/contracts/dao_psp22/lib.rs
https://github.com/realtakahashi/dao4commons.wasm/blob/main/contracts/dao_psp22/lib.rs

Libraries you should know first

let caller = self.env().caller();
let value = self.env().transferred_value();
https://paritytech.github.io/ink/ink_env/

Use “String” type and “Vec” type

https://github.com/realtakahashi/polkadot_js_examples/blob/main/flipper/lib.rs

Define your own struct

https://github.com/realtakahashi/polkadot_js_examples/blob/main/flipper/lib.rs

How To Test

Off-Chain Test

cargo +nightly test

On-Chain Test

./astar-collator --dev -lruntime=debug

How To Debug

ink_env::debug_println!("########## destination caller ############### value is {:?}", caller);
https://github.com/realtakahashi/delegate_test/blob/main/destination/lib.rs
--dev -lruntime=debug

Useful Tools

Openbrush

Swanky

Next Step

About Astar

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store