Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 1.35 KB

README.md

File metadata and controls

45 lines (33 loc) · 1.35 KB

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