0.1.5 • Published 1 year ago

wds-near-contract-parser v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

NEAR Contract Parser

npm.io npm.io

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