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

multicall-decode

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multicall-decode

EVM multicall calldata decoder

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

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 :

PropertyTypeDescriptionOptional
signaturestringThe signature of the candidate functionNo
_idnumberThe id of the candidate functionNo
parametersarrayAn array of Parameter objects describing the function's inputYes
validbooleanA 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 :

PropertyDescription
typeThe type of the parameter (e.g., address)
_idThe ID of the parameter / Index in the function's signature
valueThe value of the parameter as returned by Web3

Keywords

FAQs

Package last updated on 15 Apr 2022

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