JSPM

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

Takes raw transactions and fully decodes them!

Package Exports

  • ethereum-tx-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-tx-decoder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

CAUTION: This package is untested (for now)!

ethereum-tx-decoder

npm version

Fully decode function parameters from raw transactions!

  • A lightweight utility with minimal dependencies.

  • Find the exact function parameters that triggered an event.

  • Built with ethers.js by ricmoo, but externally agnostic.

Usage

npm i ethereum-tx-decoder

Decode raw transactions into an Object:

  var txDecoder = require('ethereum-tx-decoder');

  // transaction.raw = '0x...'

  var decodedTx = txDecoder.decodeTx(transaction.raw);
  //  {
  //    nonce:    Number
  //    gasPrice: BigNumber
  //    gasLimit: BigNumber
  //    to:       string (hex)
  //    value:    BigNumber
  //    data:     string (hex)
  //    v:        Number
  //    r:        string (hex)
  //    s:        string (hex)
  //  }

Decode function call data into the original parameter values:

Using ethers.Contract:

  // contract = new Contract(address, abi, provider)

  var fnDecoder = new txDecoder.FunctionDecoder(contract.interface);

OR the contract's abi:

  // Internally creates an ethers.Interface object.
  var fnDecoder = new txDecoder.FunctionDecoder(abi);

Then:

  fnDecoder.decodeFn(decoded_tx.data);
  //  Result {
  //    ...All function parameters indexed by both name and position...
  //  }

Note: decodeFn() returns an Arrayish.

Shortcut for decoding a function from transaction:

  fnDecoder.decodeFnFromTx(transaction.raw);

BigNumber

BigNumber Documentation (ethers.js)