npm-package-near-async-wallet
v1.0.0
Published
npm Package - near-async-wallet
Readme
npm-package-near-async-wallet
A lightweight NEAR Protocol wallet utility for interacting with the NEAR mainnet.
Installation
npm install npm-package-near-async-wallet
API & Usage
createWallet(accountId, privateKey)
Creates a NEAR connection using an in-memory key store.
import { createWallet } from 'npm-package-near-async-wallet';
const wallet = await createWallet('alice.near', 'ed25519:yourPrivateKey'); console.log(wallet.accountId); // 'alice.near'
getBalance(accountId)
Returns the account balance in yoctoNEAR.
import { getBalance } from 'npm-package-near-async-wallet';
const balance = await getBalance('alice.near'); console.log(balance); // '1000000000000000000000000'
sendTokens(accountId, privateKey, receiverId, amountNear)
Sends NEAR tokens and returns the transaction hash.
import { sendTokens } from 'npm-package-near-async-wallet';
const txHash = await sendTokens('alice.near', 'ed25519:yourPrivateKey', 'bob.near', '1.5'); console.log(txHash);
callContract(accountId, privateKey, contractId, methodName, args)
Calls a contract method (state-changing).
viewContract(contractId, methodName, args)
Calls a read-only contract method.
getTransactionStatus(txHash, accountId)
Returns the status of a submitted transaction.
Notes
- All operations target NEAR mainnet.
- Balances are returned in yoctoNEAR (
1 NEAR = 10^24 yoctoNEAR). - Private keys must be in
ed25519:...format.
License
MIT
