https://github.com/maticnetwork/eth-decoder
Simple library to decode ethereum transaction and logs
https://github.com/maticnetwork/eth-decoder
ethereum smart-contracts truffle web3
Last synced: about 2 months ago
JSON representation
Simple library to decode ethereum transaction and logs
- Host: GitHub
- URL: https://github.com/maticnetwork/eth-decoder
- Owner: maticnetwork
- License: mit
- Archived: true
- Created: 2018-09-20T19:33:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-05-13T08:58:24.000Z (about 2 years ago)
- Last Synced: 2025-04-13T01:39:41.772Z (2 months ago)
- Topics: ethereum, smart-contracts, truffle, web3
- Language: TypeScript
- Homepage:
- Size: 429 KB
- Stars: 39
- Watchers: 5
- Forks: 15
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eth-decoder

Simple library to decode ethereum transaction and logs
### Install
```bash
$ npm install --save @maticnetwork/eth-decoder
```### Usage
**Log parser**
```js
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**
```js
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