Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 8 days ago
JSON representation
Simple library to decode ethereum transaction and logs
- Host: GitHub
- URL: https://github.com/maticnetwork/eth-decoder
- Owner: maticnetwork
- License: mit
- Created: 2018-09-20T19:33:02.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-05-13T08:58:24.000Z (over 1 year ago)
- Last Synced: 2024-10-30T07:19:53.890Z (18 days ago)
- Topics: ethereum, smart-contracts, truffle, web3
- Language: TypeScript
- Homepage:
- Size: 429 KB
- Stars: 37
- Watchers: 6
- Forks: 15
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eth-decoder
![Build Status](https://github.com/maticnetwork/eth-decoder/workflows/CI/badge.svg?branch=master)
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