npm-package-near-batch-transaction
v1.0.0
Published
npm Package - near-batch-transaction
Readme
npm-package-near-batch-transaction
A lightweight utility for building and sending batch transactions on the NEAR blockchain.
Installation
npm install npm-package-near-batch-transaction
API
getAccessKeyInfo(accountId, publicKey)
Fetch the current nonce and block hash for a given account and public key.
getAccountBalance(accountId)
Retrieve the NEAR balance for a given account.
buildBatchTransaction(actions)
Build a batch transaction from an array of BatchAction objects without sending it.
sendBatchTransaction(actions)
Build and send a batch transaction to the NEAR mainnet RPC.
Usage
import { getAccessKeyInfo, getAccountBalance, buildBatchTransaction, sendBatchTransaction, BatchAction, } from 'npm-package-near-batch-transaction';
// Get access key info const { nonce, blockHash } = await getAccessKeyInfo( 'alice.near', 'ed25519:YourPublicKey...' );
// Get account balance const balance = await getAccountBalance('alice.near');
// Define batch actions const actions: BatchAction[] = [ { type: 'transfer', receiverId: 'bob.near', amount: '1000000000000000000000000' }, { type: 'functionCall', methodName: 'stake', args: { amount: '500000000000000000000000' }, gas: '30000000000000', deposit: '0', }, ];
// Build without sending const tx = await buildBatchTransaction(actions);
// Build and send const result = await sendBatchTransaction(actions);
if (result.success) { console.log('Transaction hash:', result.transactionHash); } else { console.error('Error:', result.error); }
License
MIT
