This contract implements simple counter backed by storage on blockchain.
assembly/main.ts 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, counter will add or minus 10 a time. RS button is for reset. LE and RE buttons to let the robot wink to you.
Open in the Gitpod link above or clone the repository.
git clone https://github.com/near-examples/counter
Make sure you have
near-shell by running:
If you need to install
npm install near-shell -g
If you do not have a NEAR account, please create one with NEAR Wallet.
In the project root, login with
near-shell 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!
yarn asp # as-pect tests NODE_ENV=ci yarn jest # jest tests NODE_ENV=ci yarn test # both
assembly/main.tsfor the contract code
src/index.htmlfor the front-end HTML
src/test.jsfor the JS tests for the contract