eth-decoder
v0.0.1-beta.2
Published
Simple library to decode ethereum logs and transaction
Downloads
19
Readme
eth-decoder
Simple library to decode ethereum transaction and logs
Install
$ npm install --save eth-decoder
Usage
Log parser
import { LogDecoder } from "eth-decoder"
const ERC20TokenABI = /* { .... } */ // ABI for ERC20 token contract
// create decoder object
const decoder = new LogDecoder(
[
ERC20TokenABI,
// ... other ABIs
]
);
// parse logs
const parsedLogs = decoder.decodeLogs(receipt.logs) // For truffle testsuite, use `receipt.receipt.logs`
console.log(parsedLogs)
Tx parser
import { TxDecoder } from "eth-decoder"
const ERC20TokenABI = /* { .... } */ // ABI for ERC20 token contract
// create decoder object
const decoder = new TxDecoder(
[
ERC20TokenABI,
// ... other ABIs
]
);
// parse tx
const parsedTx = decoder.decodeTx({ data: '0x..', value: '1000', from: '...', ... })
console.log(parsedTx)
License
MIT