This contract implements simple counter backed by storage on blockchain.
contract/src/lib.rs provides methods to increment / decrement counter and get it's current value or reset.
Plus and minus buttons increase and decrease value correspondingly. When button L is toggled, a little light turns on, just for fun. RS button is for reset. LE and RE buttons to let the robot wink at you.
Open in the Gitpod link above or clone the repository.
git clone https://github.com/near-examples/rust-counter
If you don't have
Rust installed, complete the following 3 steps:
1) Install Rustup by running:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
2) Configure your current shell by running:
3) Add wasm target to your toolchain by running:
rustup target add wasm32-unknown-unknown
Next, make sure you have
near-cli by running:
If you need to install
npm install near-cli -g
If you do not have a NEAR account, please create one with NEAR Wallet.
In the project root, login with
near-cli by following the instructions after this command:
Modify the top of
src/config.js, changing the
CONTRACT_NAME to be the NEAR account that was just used to log in.
… const CONTRACT_NAME = 'YOUR_ACCOUNT_NAME_HERE'; /* TODO: fill this in! */ …
Start the example!
cd contract cargo test -- --nocapture
contract/src/lib.rsfor the contract code
src/index.htmlfor the front-end HTML
src/test.jsfor the JS tests for the contract
cd contract cargo doc --no-deps --open