1

I am trying to decode the transaction input which is an hex data. I am using the following code for the same

const functionABI = abi.find(entry => entry.name === 'check');
decodedInput = web3.eth.abi.decodeParameters(functionABI.inputs, transaction_value_inputhex);

But I am getting the following error:

AbiError: Parameter decoding error: overflow [ See: https://links.ethers.org/v5-errors-NUMERIC_FAULT-overflow ] (fault="overflow", operation="toNumber", value="82761115782984517887676908056636111396111210639372934339649515668971561418752", code=NUMERIC_FAULT, version=bignumber/5.7.0)
at decodeParametersWith (C:\...\App\node_modules\web3-eth-abi\src\api\parameters_api.ts:182:9)
at Object.decodeParameters (C:\...\App\node_modules\web3-eth-abi\src\api\parameters_api.ts:293:74)
at C:\...\App\read_block.js:51:33
at processTicksAndRejections (node:internal/process/task_queues:95:5) {innerError: undefined,code: 205}

Here is the function in the smart contract (.sol) file:

          // This method reads the string
 function check(string memory temp_string2) public{
    temp_string = temp_string2;
 }

Here is the code I used to add the transaction:

const result = await mycontract.methods.check(
  'my string').send( {from: accounts[1], gas: 2000000, gasLimit: 5000000 } );

I checked all the transaction hashes and block numbers, everything is correct. I am not sure what is causing this error. Below are my dependecies.

{ "name": "my_app", "version": "1.0.0", "description": "", "main": "compile.js", "scripts": { "test": "mocha" }, "author": "", "license": "ISC", "dependencies": { "@truffle/hdwallet-provider": "^1.0.41-1", "ganache": "^7.9.0", "mocha": "^10.2.0", "solc": "^0.8.0", "truffle-contract-size": "^2.0.1", "web3": "^4.0.3", "web3-eth-abi": "^4.0.3" }, "devDependencies": { "ganache-cli": "^6.12.2" } }

1 Answer 1

0

I think your issue may be caused because JavaScript doesn't support numbers that are more than 53 bits. To work with numbers that are greater than the supported limit, you can pass the number as a string.

For example consider the following code:

const tokenID = 96178001019380483532355422451609849948339356991030948866277126174730172245776;
const someContract = new ethers.Contract(contractAddress, abi ,account)
const result = await someContract.safeTransferFrom(address1, address2, tokenID, 1);

The safeTransferFrom contract call would fail with the same NUMERIC_FAULT-overflow error.

To fix this we can simply wrap the tokenID with quotation marks:

const tokenID = "96178001019380483532355422451609849948339356991030948866277126174730172245776";
const someContract = new ethers.Contract(contractAddress, abi ,account)
const result = await someContract.safeTransferFrom(address1, address2, tokenID, 1);

You can see this link for the same issue from the ethers js GitHub discussions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.