New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eth-method-registry

Package Overview
Dependencies
Maintainers
12
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eth-method-registry

A module for getting method signature info from an ethereum method signature.

  • 4.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
12
Created
Source

Eth Method Registry

A javascript library for getting Solidity method data from a four-byte method signature.

Currently uses the parity on-chain method registry, but eventually I am interested in adding various parallel methods, whatever works and returns a valid response!

Installation

With Node.js Installed:

yarn install eth-method-registry -S

Usage

const { MethodRegistry } = require('eth-method-registry')
const Eth = require('@metamask/ethjs')

const provider = new Eth.HttpProvider('https://mainnet.infura.io/v3/YOUR-PROJECT-ID')
const registry = new MethodRegistry({ provider })

// Uses promises, pass the 4byte prefix to the lookup method:
registry.lookup('0xa9059cbb')
  .then((result) => {
   console.log(result) // prints 'transfer(address,uint256)'
  })

// Also includes a method for parsing the resulting sig
// into something more useful for rendering:
const sig = 'transferFrom(address,uint256)'
const parsed = registry.parse(sig)
/* Parsed value:
   {
    name :'Transfer From',
    args: [
      { type: 'address' },
      { type: 'uint256' }
    ]
   }
*/

Development

The unit tests of this package run against Infura's v3 API. After cloning this repository, run cp .infurarc.template .infurarc and add your Infura project ID to the file.

Running Tests

yarn test

Keywords

FAQs

Package last updated on 07 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc