Calvin Torra
1 min readSep 23, 2022

--

There are two ways to view and interact with data on the NEAR blockchain.

1. Change Methods

Change methods execute functions on smart contracts. These then get proved on the blockchain and they allow us to change the state of a smart contract.

ex: Wanting to transfer an NFT from one owner to another.

Data/State has to be updated, which means there’s a fee to execute this as an “Attached Deposit”.

DOCS

await contract.method_name({
callbackUrl: "https://example.com/callback", // callbackUrl after the transaction approved (optional)
meta: "some info", // meta information NEAR Wallet will send back to the application. `meta` will be attached to the `callbackUrl` as a url search param
args: {
arg_name: "value" // argument name and value - pass empty object if no args required
},
gas: 300000000000000, // attached GAS (optional)
amount: 1000000000000000000000000 // attached deposit in yoctoNEAR (optional)
});

2. View Methods — FREE

These are read-only methods that also live in smart contracts but don’t change the state or data on chain.

ex: Viewing the NFT an owner has from a specific collection.

This is just returning existing state in read only and is free to call and view.

DOCS

const response = await contract.view_method_name({ arg_name: "arg_value" });
console.log(response);

--

--