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 🙏

© 2024 – Pkg Stats / Ryan Hefner

multicall-decode

v1.0.2

Published

EVM multicall calldata decoder

Downloads

13

Readme

multicall-decode

EVM multicall calldata decoder

Install

npm install multicall-decode

Basic Usage : with a direct abi encoded bytes[]

const { decodeRaw } = require("multicall-decode");
const CALLDATA =
  "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008413ead5620000000000000000000000005c8cd1c2f2997f7a041026cc29de8177b4c6d8ec00000000000000000000000089e54f174ca5ff39cf53ab58004158e2ca012eac0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000035f2482336c0d4c2ba6e94faa1d66f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000164883164560000000000000000000000005c8cd1c2f2997f7a041026cc29de8177b4c6d8ec00000000000000000000000089e54f174ca5ff39cf53ab58004158e2ca012eac0000000000000000000000000000000000000000000000000000000000000bb8fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2764c00000000000000000000000000000000000000000000000000000000000a11a8000000000000000000000000000000000000000000000000000000e8d4a510000000000000000000000000000000000000000000000a56d35c029fd16645e079000000000000000000000000000000000000000000000000000000e840308c030000000000000000000000000000000000000000000a503344abc0fbe23670910000000000000000000000005a2b5cb4ce921abd65f0c66c2c839894bfc2076c000000000000000000000000000000000000000000000000000000006244356a00000000000000000000000000000000000000000000000000000000";
  
async function main() {
  console.log(await decodeRaw(CALLDATA));
}

main();

//[
//  [
//    {
//      signature: 'mint((address,address,uint24,int24,int24,uint256,uint256,uint256,uint256,address,uint256))',
//      _id: 0,
//      parameters: [Array],
//      valid: true
//    }
//  ],
//  [
//    {
//      signature: 'createAndInitializePoolIfNecessary(address,address,uint24,uint160)',
//      _id: 0,
//      parameters: [Array],
//      valid: true
//    }
//  ]
//]

Basic Usage : with an abi decoded array of bytes

const { decodeCalls } = require("multicall-decode");
const Web3 = require('web3');
const CALLDATA =
  "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008413ead5620000000000000000000000005c8cd1c2f2997f7a041026cc29de8177b4c6d8ec00000000000000000000000089e54f174ca5ff39cf53ab58004158e2ca012eac0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000035f2482336c0d4c2ba6e94faa1d66f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000164883164560000000000000000000000005c8cd1c2f2997f7a041026cc29de8177b4c6d8ec00000000000000000000000089e54f174ca5ff39cf53ab58004158e2ca012eac0000000000000000000000000000000000000000000000000000000000000bb8fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2764c00000000000000000000000000000000000000000000000000000000000a11a8000000000000000000000000000000000000000000000000000000e8d4a510000000000000000000000000000000000000000000000a56d35c029fd16645e079000000000000000000000000000000000000000000000000000000e840308c030000000000000000000000000000000000000000000a503344abc0fbe23670910000000000000000000000005a2b5cb4ce921abd65f0c66c2c839894bfc2076c000000000000000000000000000000000000000000000000000000006244356a00000000000000000000000000000000000000000000000000000000";
  
const web3 = new Web3();

async function main() {
  const calls = web3.eth.abi.decodeParameter("bytes[]", CALLDATA);
  console.log(await decodeCalls(calls));
}

main();

//[
//  [
//    {
//      signature: 'mint((address,address,uint24,int24,int24,uint256,uint256,uint256,uint256,address,uint256))',
//      _id: 0,
//      parameters: [Array],
//      valid: true
//    }
//  ],
//  [
//    {
//      signature: 'createAndInitializePoolIfNecessary(address,address,uint24,uint160)',
//      _id: 0,
//      parameters: [Array],
//      valid: true
//    }
//  ]
//]

Input

The input of decodeRaw is expected to be an abi encoded hex string representing a bytes[].

The input of decodeCalls is expected to be an abi decoded array of bytes.

Output

The output is an array containing one set of candidates for each call embedded in the input.

Each set of candidates is itself an array of objects, each object describes a candidate call :

| Property | Type | Description | Optional | |:------------:|:--------:|:-------------------------------------------------------------:|:------------:| | signature | string | The signature of the candidate function | No | | _id | number | The id of the candidate function | No | | parameters | array | An array of Parameter objects describing the function's input | Yes | | valid | boolean | A boolean value stating the validity of this candidate. | No |

If decoding was successfull, the parameters of a valid candidate are present in the parameters array :

| Property | Description | |:------------:|:-----------------------------------------------------------:| | type | The type of the parameter (e.g., address) | | _id | The ID of the parameter / Index in the function's signature | | value | The value of the parameter as returned by Web3 |