ethereum-tx-decoder
Lightweight utility for decoding function parameters from Ethereum transactions.
-
Minimal dependencies.
-
Find the exact function parameters that triggered an event.
Usage
npm i ethereum-tx-decoder
decodeTx()
Decode raw transactions into an Object.
var txDecoder = ; // transaction.raw = '0x...' var decodedTx = txDecoder; // { // 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.
ethers.Contract
:
New instance with // contract = new Contract(address, abi, provider) var fnDecoder = contractinterface;
abi
:
New instance with contract // Internally creates an ethers.Interface object. var fnDecoder = abi;
decodeFn()
fnDecoder; // Result { // ...All function parameters indexed by both name and position... // }
Note: decodeFn()
returns an Arrayish
.
decodeFnFromTx()
Shortcut for decoding a function from transaction.
fnDecoder;