npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@exodus/solidity-contract

v1.3.1

Published

Object orient smart contract ABI data building/parsing.

Readme

solidity-contract

Object-oriented ABI data building and parsing for Ethereum Smart Contracts.

API

new SolidityContract(abi, address)

  • abi: Array | String The contract's ABI, as a parsed JSON array, or JSON string.
  • address: String (optional)

Creates a new SolidityContract instance, and populates the methods and events of the contract with the methods and events in the ABI.

SolidityContract instance properties

  • contract.abi: Array<Object>

The parsed ABI Array as passed to the constructor.


  • contract.address: String

The contract address string as passed to the constructor. This address isn't used for anything at present.


  • contract.methodIds: Object<String:Object>

An object mapping method ID strings to the ABI method object specifying the details of that method. All method ID string keys are lower case hex strings prefixed with '0x'.

const { methodId, name, stateMutability, payable, constant, type, inputs, outputs } =
  contract.methodIds['0x01234567']

  • contract[eventName]

For every event in the contract's ABI, the contract instance has the event added as a property. For example, an ERC20 token contract would have contract.Transfer and contract.Approval.

Each of these properties is an object which has the following properties and methods:

  • build: (...any) => Buffer UNIMPLEMENTED
  • parse: (callData: String | Buffer) => Array<any> Parse ABI event log data calling and return the parsed values. The values' types depend on the types of the input parameters in the ABI specification. For example, a string type would return a string, a uint would return a stringified number in base 10, a bytes value would return a Buffer, etc. Must the event's raw unindexed log data.
  • testInput: (String | Buffer) => boolean UNIMPLEMENTED
  • eventId: String The event ID hex string.
  • abi: Object The ABI specification for this event as passed to the constructor.

  • contract.eventIds: Object<String:Object>

Same as contract.methodIds, except for contract events instead. Event IDs in solidity are represented in long-form, as full 32 byte Keccak hash, rather than the short 4-byte form used for method IDs.

const { eventId, name, type, inputs, anonymous } =
  contract.eventIds['0xb5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c']

  • contract[methodName]: Object

For every function on the contract's ABI, the contract instance has the method added as a property. For example, a contract instantiated with an ERC20 token ABI would have contract.transfer, contract.approve, etc.

Each of these properties is an object which has the following properties and methods:

  • build: (...any) => Buffer Build ABI transaction data calling methodName with the supplied parameters. For example, you could call token.transfer('0x' + '0'.repeat(40), 100000) to build the data for a transfer of 100000 wei for any ERC20 token.
  • parse: (callData: String | Buffer) => Array<any> Parse ABI transaction data calling this function and return the parsed values. The values' types depend on the types of the input parameters in the ABI specification. For example, a string type would return a string, a uint would return a stringified number in base 10, a bytes value would return a Buffer, etc. Must supply call data without the 4 method ID prefix bytes.
  • testInput: (String | Buffer) => boolean Check if the input data is valid for this method.
  • methodId: String The method ID hex string.
  • abi: Object The ABI specification for this method as passed to the constructor.
const callData = tokenContract.balanceOf.build(address)
console.log(Buffer.isBuffer(callData)) // true
console.log(tokenContract.balanceOf.testInput(callData)) // true

  • contract[eventName]: Object

For every event in the contract's ABI, the contract instance has the event added as a property. For example, an ERC20 SolidityContract instance has contract.Transfer, contract.Approval, etc.

Each of these properties is equal to the ABI specification object for this event, plus an eventId hex string property. See contract.eventIds[eventId].

SolidityContract instance methods


  • decodeInput(callData: String | Buffer): { method: string, values: Array<any> }

Decode the given call data and attempt to identify which method on the contract was being called. If successful, decode the input parameters and return them in the values array. If unsuccessful, an error is thrown.

SolidityContract static methods


  • SolidityContract.erc20(address: String): SolidityContract

Return a contract implementing the full ERC20 token standard. address parameter is optional.


  • SolidityContract.simpleErc20(address: String): SolidityContract

Returns a contract implementing only the following ERC20 methods and event:

transfer(address,uint256)
balanceOf(address)
Transfer(address,address,uint256)

address parameter is optional.


  • SolidityContract.simpleErc721(address: String): SolidityContract

Returns a contract implementing only the following ERC721 methods:

ownerOf(uint256)
tokenURI(uint256)
uri(uint256)
symbol()
totalSupply()
safeTransferFrom(address,address,uint256)

address parameter is optional.