Consensys / Consensys/abi-decoder

Cannot decode tx data

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

Description

This is somewhat an edge case but the ERC20 token transfer for this [transaction](https://etherscan.io/tx/0xd4b9846901eaf92b29678ce7003b46c876cf19153022d20229d4bd2ca3b9897d) cannot be decoded. I am not sure whether I should open an issue here or @ethersproject/abi.

### Sample Code
```
const abiDecoder = require('abi-decoder');
const testABI = [{
"constant": false,
"inputs": [
{
"name": "_to",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}];
abiDecoder.addABI(testABI);
const testData = "0xa9059cbb0000000000000000000000043f47038d2b20566700a38cd718a537103f7696c9000000000000000000000000000000000000000000000000000000000903c63c";
const decodedData = abiDecoder.decodeMethod(testData);
console.log(decodedData);
```
### Exception
```
/home/ubuntu/node_modules/@ethersproject/abi/lib/coders/array.js:139
get: function () { throw value; }
^

_to: value out of range (argument="value", value=20, code=INVALID_ARGUMENT, version=bytes/5.0.1)
at Logger.makeError (/home/ubuntu/node_modules/@ethersproject/logger/lib/index.js:179:21)
at Logger.throwError (/home/ubuntu/node_modules/@ethersproject/logger/lib/index.js:188:20)
at Logger.throwArgumentError (/home/ubuntu/node_modules/@ethersproject/logger/lib/index.js:191:21)
at Object.hexZeroPad (/home/ubuntu/node_modules/@ethersproject/bytes/lib/index.js:263:16)
at AddressCoder.decode (/home/ubuntu/node_modules/@ethersproject/abi/lib/coders/address.js:34:45)
at /home/ubuntu/node_modules/@ethersproject/abi/lib/coders/array.js:93:31
at Array.forEach ()
at Object.unpack (/home/ubuntu/node_modules/@ethersproject/abi/lib/coders/array.js:71:12)
at TupleCoder.decode (/home/ubuntu/node_modules/@ethersproject/abi/lib/coders/tuple.js:39:49)
at AbiCoder.decode (/home/ubuntu/node_modules/@ethersproject/abi/lib/abi-coder.js:93:22) {
reason: 'value out of range',
code: 'INVALID_ARGUMENT',
argument: 'value',
value: 20,
baseType: 'address',
name: '_to',
type: 'address'
}
```

I think that there is a typo in the input data for the address parameter and this causes a problem. There is a 4 instead of 0 (I added spaces before and after to make it more readable.)

Function signiture: 0xa9059cbb
Address: 00000000000000000000000 **4** 3f47038d2b20566700a38cd718a537103f7696c9
Value: 000000000000000000000000000000000000000000000000000000000903c63c

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the sample through abiDecoder.decodeMethod with the supplied transaction data and ABI, then inspect the decoder path that delegates to @ethersproject/abi. Compare the malformed address word with the reported exception and determine the expected handling for this input. Done means the issue's behavior is understood and a verified fix or explicit rejection is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
blockchain
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.