Consensys / Consensys/abi-decoder

Can decode receipt.logs, but not an input for the same transaction

Open
#30 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
641
Forks
215
PR merge metrics
No merged PRs in 30d

Description

abi-decoder works great for receipt.logs, but now I want to process pending transaction, so I need to decode an input. But it returns undefined.

Here is an example ([transaction](https://etherscan.io/tx/0xdedeeb95961f8ce3eed570abec386759f45ce29b694993a3916d2001ed41bd37), [0x exchange ABI](http://api.etherscan.io/api?module=contract&action=getabi&address=0x4f833a24e1f95d70f028921e27040ca56e09ab0b&format=raw)):
```
const Web3 = require('web3')
const web3 = new Web3(new Web3.providers.WebsocketProvider('wss://mainnet.infura.io/ws'))
const abiDecoder = require('abi-decoder')

const contract_artifacts = require('@0x/contract-artifacts')

Object.keys(contract_artifacts).forEach(function(key,index) {
abiDecoder.addABI(contract_artifacts[key].compilerOutput.abi)
})

const tx = '0xdedeeb95961f8ce3eed570abec386759f45ce29b694993a3916d2001ed41bd37'
web3.eth.getTransactionReceipt(tx).then(receipt=>{ console.log(abiDecoder.decodeLogs(receipt.logs)) })
```
It works great, there are three decoded events.
But if I'm trying
```
web3.eth.getTransaction(tx).then(transaction=>{console.log(abiDecoder.decodeMethod(transaction.input))})
```
or just
```
abiDecoder.decodeMethod('0xb4be83d500000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000007c4c5a0e0ae4700000000000000000000000000000000000000000000000000000000000002a00000000000000000000000003496b716605d96ecb50c10fea2e0baf11439bd7c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a258b39954cef5cb142fd567a46cddb31a6701240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018ca8441e3dfb5be600000000000000000000000000000000000000000000000000de0b6b3a764004f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005c35f0b10000000000000000000000000000000000000000000000000000016832b0cc35000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000421bee193754d40cb289ab679379163d91e259b19cd4d3ddfc6de1890a2301a301337fa8518c89e9a67e5038f5de3b1d9664ac302c62fc5f65b212b576888eb3ac4f03000000000000000000000000000000000000000000000000000000000000')
```
then I'm getting ```undefined``` (however I can decode this data using [ethereum-tx-decoder](https://github.com/GFJHogue/ethereum-tx-decoder) and 0x exchange ABI).

It looks like an issue, but maybe I'm just doing something wrong?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.