Integrating with NEAR Protocol

  • Proof of Stake
  • Sharded
  • WASM Smart Contracts
DISCLAIMER: This will not take you more than 30 minutes if you can program in TypeScript.
git clone https://github.com/near-examples/counter
yarn
We only care about these 2 folders and 1 file
https://github.com/near/near-sdk-as/tree/master/sdk-core/assembly/collections
  • storage.getPrimitive — get/set
  • persistentMap — set/get
  • persistentUnorderedMap — set/get/query/length
let balance = myPersistentMap.get("myacc.near", u128.Zero)!
npm install near-cli -g
yarn build
ACC1=$(near dev-deploy out/main.wasm | sed 's/.*id: \(.*\), node.*/\1/' | head -n 1)
near view --accountId $ACC1 $ACC1 getCounter '{}'
View call: dev-1623290109414-64922580028342.getCounter({})
0
near call --accountId $ACC1 $ACC1 incrementCounter '{"value": 1}'
node << EOF
const fetch = require('node-fetch');
async function go() {
const args_base64 = Buffer.from('{}').toString('base64')
const params = {account_id: "zodtv.near", method_name: "mint_status",
request_type: "call_function", finality: "final", "args_base64": args_base64}
const json_args = {jsonrpc: "2.0", id: "1", method: "query", params: params}

const fetch_args = {
method: "POST",
body: JSON.stringify(json_args),
headers: {
"Content-Type": "application/json"
}
}
const response = await fetch("https://rpc.mainnet.near.org", fetch_args);
const {result} = await response.json();

const mint_status = JSON.parse((new TextDecoder()).decode(new Uint8Array(result.result)))
console.log(mint_status)
}
go()
EOF
{
"total_minted": "3120000000000000000000000000",
"level": "0",
"near_price": "3000000000000000000000000",
"zod_price": "10000000000000000000000"
}

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

LEAVE THE HARDWARE ALONE!

Odoo for Manufacturing: MRP, PLM, and Maintenance — RT Dynamic

How to benefit from your PACS being in the cloud

Must know basics for Software Engineers :[OSI Model : What Is the Transport Layer? — PART-1]

Flutter :- Material App

Do it yourself Rescheck

About that ageing Programmer

CSS for Dummies: Taking Your Rails App from Basic to Bougie

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
vans163

vans163

More from Medium

Introducing Galleon DAO — DeFi Structured Products Methodologists & 17th-Century Roleplay

Saber launches Eversol eSOL-SOL pool on Solana!

Gro Integrates Industry-Leading Oracle Solution Chainlink for Enhanced Price Accuracy

Announcing Incept’s V1: Polaris