@tonic-foundation/near-contract-parser
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

NEAR Contract Parser

Collection of utilities for parsing base64-encoded WASM smart contracts on NEAR Protocol, extracting exported members, and detecting likely candidates for standard contract interface implementation.

Usage

Installation

$ npm install --save near-contract-parser

Example

const { Near, keyStores } = require('near-api-js');
const { parseContract } = require('near-contract-parser');

const near = new Near({
  networkId: 'mainnet',
  keyStore: new keyStores.InMemoryKeyStore(),
  nodeUrl: 'https://rpc.mainnet.near.org',
  walletUrl: 'https://wallet.mainnet.near.org',
  helperUrl: 'https://helper.mainnet.near.org',
  explorerUrl: 'https://explorer.mainnet.near.org',
});

(async () => {
  const account_id = 'CONTRACT_ACCOUNT_ID.near';
  const { code_base64 } = await near.connection.provider.query({
    account_id,
    finality: 'final',
    request_type: 'view_code',
  });

  console.log(parseContract(code_base64));
})();

Authors

Package Sidebar

Install

npm i @tonic-foundation/near-contract-parser

Weekly Downloads

2

Version

0.1.5

License

MIT

Unpacked Size

24.8 kB

Total Files

26

Last publish

Collaborators

  • markobosnic
  • renthog