npm-package-near-secure-transaction
v1.0.0
Published
npm Package - near-secure-transaction
Readme
npm-package-near-secure-transaction
A lightweight utility package for interacting with the NEAR blockchain — fetch account details, check transaction status, call view methods, validate account IDs, and retrieve the latest block height.
Installation
npm install npm-package-near-secure-transaction
Functions
getAccountDetails(accountId, networkId?)— Fetch balance, nonce, and code hash for a NEAR account.getTransactionStatus(txHash, senderId, networkId?)— Get the status of a submitted transaction.callViewMethod(contractId, methodName, args, networkId?)— Call a read-only contract method.validateAccountId(accountId)— Validate whether a string is a valid NEAR account ID.getLatestBlockHeight(networkId?)— Retrieve the most recent block height from the network.
Usage
import { getAccountDetails, getTransactionStatus, callViewMethod, validateAccountId, getLatestBlockHeight, } from "npm-package-near-secure-transaction";
// Fetch account details (defaults to mainnet) const account = await getAccountDetails("alice.near", "mainnet"); console.log(account.amount, account.nonce, account.code_hash);
// Check transaction status const status = await getTransactionStatus("Tx123...", "alice.near", "testnet");
// Call a view method on a contract const result = await callViewMethod("contract.near", "get_balance", { account_id: "alice.near" });
// Validate an account ID const isValid = validateAccountId("alice.near"); // true
// Get latest block height const height = await getLatestBlockHeight("mainnet"); console.log(height);
License
MIT
