npm-package-near-async-account
v1.0.0
Published
npm Package - near-async-account
Readme
npm-package-near-async-account
Lightweight utilities for querying NEAR Protocol account data and transactions via the mainnet RPC.
Installation
npm install npm-package-near-async-account
Functions
getAccountState(accountId)— Full account state: balance, storage, code hashaccountExists(accountId)— Returnstrue/falsegetAccessKeys(accountId)— All access keys for an accountgetAccountBalance(accountId)— Available, staked, and total balancegetTransactionDetails(txHash, senderId)— Transaction result and statuscallViewFunction(contractId, methodName, args)— Call a read-only contract method
Usage
import { getAccountState, accountExists, getAccessKeys, getAccountBalance, getTransactionDetails, callViewFunction, } from "npm-package-near-async-account";
// Check if account exists const exists = await accountExists("alice.near");
// Get full account state const state = await getAccountState("alice.near"); console.log(state.amount, state.code_hash);
// Get access keys const keys = await getAccessKeys("alice.near");
// Get balance const balance = await getAccountBalance("alice.near");
// Get transaction details const tx = await getTransactionDetails("Fy7...hash", "alice.near");
// Call a view function const result = await callViewFunction("wrap.near", "ft_balance_of", { account_id: "alice.near", });
Notes
- Targets NEAR mainnet (
https://rpc.mainnet.near.org) - All functions are async and throw on RPC errors
- Peer dependency:
near-api-js
License
MIT
