npm-package-near-secure-contract
v1.0.0
Published
npm Package - near-secure-contract
Readme
npm-package-near-secure-contract
Utilities for securely inspecting and verifying NEAR Protocol smart contracts via the mainnet RPC.
Installation
npm install npm-package-near-secure-contract
API & Usage
import { getContractState, viewContractMethod, getContractCodeHash, verifyTransaction, isContractDeployed, getContractAccessKeys, } from 'npm-package-near-secure-contract';
Fetch raw contract state
const state = await getContractState('example.near'); console.log(state); // Record<string, string>
Call a view method
const result = await viewContractMethod('example.near', 'get_balance', { account_id: 'user.near' }); console.log(result);
Get contract code hash
const hash = await getContractCodeHash('example.near'); console.log(hash); // SHA-256 hash string
Verify a transaction
const isValid = await verifyTransaction('txHashHere', 'sender.near'); console.log(isValid); // boolean
Check if a contract is deployed
const deployed = await isContractDeployed('example.near'); console.log(deployed); // true | false
Get contract access keys
const keys = await getContractAccessKeys('example.near'); console.log(keys); // array of access key objects
Notes
- All calls target
https://rpc.mainnet.near.org - Functions are async and throw on RPC errors
- Built on top of
near-api-js
License
MIT
