🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

ethereum-tx-decoder

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereum-tx-decoder

Lightweight utility for decoding function parameters from Ethereum transactions.

3.0.0
latest
Source
npm
Version published
Weekly downloads
1K
-50.22%
Maintainers
1
Weekly downloads
 
Created
Source

ethereum-tx-decoder

npm versionBuild Status

Lightweight utility for decoding function parameters from Ethereum transactions.

  • Minimal dependencies.

  • Find the exact function parameters that triggered an event.

  • Built with ethers.js by ricmoo.

Usage

npm i ethereum-tx-decoder

decodeTx()

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)
  //  }

Need to know from or chainId? Use ethers.Wallet.parseTransaction() instead.

class FunctionDecoder

Decode function call data into the original parameter values.

New instance with ethers.Contract:

  // contract = new Contract(address, abi, provider)
  var fnDecoder = new txDecoder.FunctionDecoder(contract.interface);

New instance with contract abi:

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

decodeFn()

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

Note: decodeFn() returns an Arrayish.

decodeFnFromTx()

Shortcut for decoding a function from transaction.

  fnDecoder.decodeFnFromTx(transaction.raw);

BigNumber

BigNumber Documentation (ethers.js)

Keywords

ethereum

FAQs

Package last updated on 23 Sep 2019

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