This contract implements simple counter backed by storage on blockchain.
Contract in 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
Install dependencies:
yarn --frozen-lockfile
Make sure you have near-cli
by running:
near --version
If you need to install near-cli
:
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:
near login
Modify the top of src/config.js
, changing the CONTRACT_NAME
to be the NEAR account name in the file neardev/dev-account
. It starts with dev-
.
Modify the top of src/config.js
, We need to change wallet address on testnet, example: const CONTRACT_NAME = 'mywallet.testnet'
Moreover, we need to add a empty file at ./neardev/dev-account.env.
…
const CONTRACT_NAME = 'neardev/dev-account ACCOUNT ID'; /* TODO: fill this in! */
…
Start the example!
yarn start
yarn asp # as-pect tests
NODE_ENV=ci yarn jest # jest tests
NODE_ENV=ci yarn test # both
assembly/main.ts
for the contract codesrc/index.html
for the front-end HTMLsrc/main.js
for the JavaScript front-end code and how to integrate contractssrc/test.js
for the JS tests for the contract