DEV Community

Giovanni Fu Lin
Giovanni Fu Lin

Posted on

NEAR JS INTRO

Useful Links:
https://github.com/near-examples/coin-flip-workshop-js/tree/coin-flip
https://www.youtube.com/watch?v=QYNyC6__pw8

Start

npm install
Enter fullscreen mode Exit fullscreen mode

Deploy

npx near dev-deploy build/contract.wasm
Enter fullscreen mode Exit fullscreen mode

Export env

export CONTRACT_NAME=dev-1662994042789-50479875102850
Enter fullscreen mode Exit fullscreen mode

View examples

npx near view $CONTRACT_NAME viewGreeting

npx near view $CONTRACT_NAME viewPoints '{"player": "'$CONTRACT_NAME'"}'
Enter fullscreen mode Exit fullscreen mode

Write examples

npx near call $CONTRACT_NAME setGreeting '{"message": "GO TEAM!"}' --accountId $CONTRACT_NAME

npx near call $CONTRACT_NAME flipCoin '{"side": "tails"}' --accountId $CONTRACT_NAME

Enter fullscreen mode Exit fullscreen mode

Start new project

npx create-near-app
Enter fullscreen mode Exit fullscreen mode

After a new deploy, it will generate a new CONTRACT_NAME under neardev/dev-account

npm run deploy
Enter fullscreen mode Exit fullscreen mode

Top comments (0)