-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
abi.decodeParams
fails to decode, value exceeds width (20 bytes)
#540
Comments
This can be related to ethers-io/ethers.js#4446 and ethers-io/ethers.js#4427. |
abi.decodeParams
failes to parse transaction, value exceeds width (20 bytes)abi.decodeParams
failes to parse, value exceeds width (20 bytes)
Web3 is able to decode the data: import { Web3 } from "web3";
const web3 = new Web3('https://mainnet.infura.io/v3/xxx');
var d = web3.eth.abi.decodeParameters(['address', 'uint256'], '0x0000000000000000000000417196a564824974842dd03cde3e3020af201baaa400000000000000000000000000000000000000000000000000000000001e8480');
console.log(d); but Ethers.js fails: import { AbiCoder } from 'ethers';
const abiCoder = new AbiCoder();
var d = abiCoder.decode(["address", "uint256"], "0x0000000000000000000000417196a564824974842dd03cde3e3020af201baaa400000000000000000000000000000000000000000000000000000000001e8480");
console.log(d); |
abi.decodeParams
failes to parse, value exceeds width (20 bytes)abi.decodeParams
fails to decode, value exceeds width (20 bytes)
Since Tron address is not the same as ethereum, you have to change the address data in the method data. For your scenario, you need to change the |
@start940315 what you said has nothing to do with the issue. |
Your abi contains address-type data. Currently, TronWeb doesn't convert the Tron addresses to Ethereum addresses. You have to replace it yourself. As for using web3, it seems that it is not in our development roadmap. |
@start940315 So you provide |
It supports address type, but you must change the data a little. The decoded result of the address type is Tron address. |
@start940315 I understand, I thought the |
Same error |
Same error. const trxId = 'e5cfca75a288a799662a3465616d9d5d3501b2d59b0760f094814b9e30b5130f';
const result = await tronWeb.trx.getTransaction(trxId);
const parameterData = result.raw_data.contract[0].parameter.value.data;
// ex) parameterData = 'a9059cbb000000000000000000000041cf74df913cda36aba624f91f55fae1f51ef05e8a000000000000000000000000000000000000000000000000000000000de34c40';
const arr = parameterData.split("");
arr[30] = '0'; // remove '4'
arr[31] = '0'; // remove '1'
const decodeResult = decodeParams(['address', 'uint256'], arr.join(''), true);
// decodedResult = [
// "41cf74df913cda36aba624f91f55fae1f51ef05e8a",
// 233000000n,
// ] |
It has no problem. |
Hello,
7e45745226085334dd91ce42a3beb76dcb3b6f164f5ec558a49abac8ba1885a0 this is a valid USDT transaction, but when I am trying to parse contract method data, I am getting the below error:
You can try:
It will first throw
TypeError: arg.substr is not a function
but the value ofarg
is the above object I provided.I am using the latest version, 6.0.0-beta.4. this bug existed in beta.3 also, so it is not because of Ethers.js version update.
The text was updated successfully, but these errors were encountered: