api to interact with the NEAR blockchain
This view call fetches lines populating the pixel board. No keys are required for view calls.
await near.view({
contractId: "berryclub.ek.near",
methodName: "get_lines",
args: {
lines: [
0,1,2,3,4,5,6,7,8,9,
10,11,12,13,14,15,16,17,18,19,
20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,37,38,39,
40,41,42,43,44,45,46,47,48,49
]
},
});
Minimal example of signing and broadcasting a smart contract call to the
draw method.
You must be signed in to draw. Click “Sign In” to connect your wallet.
await nearWallet.sendTransaction({
signerId: nearWallet.accountId(),
receiverId: "berryclub.ek.near",
actions: [
{
type: "FunctionCall",
params: {
methodName: "draw",
args: {
pixels: [{
x: 10,
y: 20,
color: 65280, // green
}],
},
gas: $$`100 Tgas`,
deposit: "0",
},
},
],
});
Fetching this account’s avocado_balance from the BerryClub contract.
| Total Supply: | 2417099.3688 🥑 |
| Your Balance: | 1583.7318 🥑 |
await near.view({
contractId: "berryclub.ek.near",
methodName: "get_account",
args: { account_id: nearWallet.accountId() },
});
You can also call contract methods that require a deposit. All transactions are signed through your connected wallet.
Learn more about NEAR transactions: NEAR documentation | Transaction Flow
await nearWallet.sendTransaction({
signerId: nearWallet.accountId(),
receiverId: "berryclub.ek.near",
actions: [
{
type: "FunctionCall",
params: {
methodName: "buy_tokens",
args: {},
gas: $$`100 Tgas`,
deposit: $$`0.1 NEAR`,
},
},
],
});