JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4180
  • Score
    100M100P100Q123100F
  • License MIT

Ethereum smart contract transaction input data decoder

Package Exports

  • ethereum-input-data-decoder

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ethereum-input-data-decoder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Ethereum input data decoder

Ethereum smart contract transaction input data decoder

Uses ethereumjs-abi for decoding.

Install

npm install ethereum-input-data-decoder

Usage

Pass decoder ABI file path to constructor:

const InputDataDecoder = require('ethereum-input-data-decoder');
const decoder = new InputDataDecoder(`${__dirname}/abi.json`);

Alternatively, you can pass ABI array object to constructor;

const abi = JSON.parse(fs.readFileSync(`${__dirname}/abi.json`));
const decoder = new InputDataDecoder(abi);

Then you can decode input data:

const data = `0x67043cae0000000000000000000000005a9dac9315fdd1c...`;
const result = decoder.decodeData(data);

console.log(result);
{
    "name": "registerOffChainDonation",
    "types": [
        "address",
        "uint256",
        "uint256",
        "string",
        "bytes32"
    ],
    "inputs": [
        <BN: 5a9dac9315fdd1c3d13ef8af7fdfeb522db08f02>,
        <BN: 58a20230>,
        <BN: 402934>,
        "BTC",
        <Buffer f3 df ... 71 c8>
    ]
}

Example input data from this transaction.

License

MIT