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

Automatically Build and Deploy Your Python Application in 4 Easy Steps

Scaffolding on skyscraper

Your Seniority Level is Determined by the Amount of Uncertainty you can Handle

Deploy your Serverless Python function locally with OpenFaas in Kubernetes

Your F1 Chatbot Monty

Learning With Pair Programming

Kotlin collections for beginners

How to root Hitech S300i

root LG

Algorithmic Trading

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

Ulord Project Progress(From November 18, 2021 to November 24, 2021)

Building a Dice Game with NEAR

QED Network: In-depth Technical Overview

MEAN MONEY STREAMING PROTOCOL AND ITS ADVANTAGE TO DEFI.