@maticnetwork/eth-decoder
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

eth-decoder

Build Status

Simple library to decode ethereum transaction and logs

Install

$ npm install --save @maticnetwork/eth-decoder

Usage

Log parser

import { LogDecoder } from "@maticnetwork/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 "@maticnetwork/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

Package Sidebar

Install

npm i @maticnetwork/eth-decoder

Weekly Downloads

13

Version

0.0.4

License

MIT

Unpacked Size

12.7 kB

Total Files

13

Last publish

Collaborators

  • jminfantepolygon
  • nitinmittal23
  • devops-polygon.technology
  • ankitboghra