ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

Error: invalid value for value.data

Open mateja176 opened this issue 1 year ago • 3 comments

Ethers Version

6.12.1

Search Terms

No response

Describe the Problem

Given the following contract:

          const contractToken = new Contract(
            tokenAddress,
            [
              'function decimals() view returns (uint8)',
              'function allowance(address owner, address spender) view returns (uint)',
              'function approve(address spender, uint value)',
            ],
            signingWallet,
          )

The approve operation works.

But throws the below described error.

Code Snippet

await (await contractToken.approve(swap.tx.txTo, MaxUint256)).wait()

Contract ABI

[
              'function decimals() view returns (uint8)',
              'function allowance(address owner, address spender) view returns (uint)',
              'function approve(address spender, uint value)',
            ],

Errors

index.ts:927 Error: invalid value for value.data (invalid data (argument="value", value="095ea7b300000000000000000000000069460570c93f9de5e2edbc3052bf10125f0ca22dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", code=INVALID_ARGUMENT, version=6.12.1)) (value={ "accessList": [  ], "blockHash": null, "blockNumber": null, "chainId": "0x1", "from": "0xBE0eB53F46cd790Cd13851d5EFf43D12404d33E8", "gas": "0xb7d0", "gasPrice": "0xee6b2800", "hash": "0x19be58d0e90632e55df97db55d1a5aaf21c856d5a58725fcf141cdccb323c51b", "input": "095ea7b300000000000000000000000069460570c93f9de5e2edbc3052bf10125f0ca22dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "maxFeePerGas": "0xee6b2800", "maxPriorityFeePerGas": "0x3b9aca00", "nonce": "0x5", "r": "0x0", "s": "0x0", "to": "0x40B38765696e3d5d8d9d834D8AaD4bB6e418E489", "transactionIndex": null, "type": "0x2", "v": "0x0", "value": "0x0" }, code=BAD_DATA, version=6.12.1)
    at makeError (chunk-3CWJQINT.js?v=37e953ff:121:15)
    at assert (chunk-3CWJQINT.js?v=37e953ff:134:11)
    at ethers.js?v=37e953ff:800:9
    at formatTransactionResponse (ethers.js?v=37e953ff:951:5)
    at BrowserProvider._wrapTransactionResponse (ethers.js?v=37e953ff:2008:36)
    at BrowserProvider.getTransaction (ethers.js?v=37e953ff:2433:17)
    at async checkTx (ethers.js?v=37e953ff:3463:23)

Environment

Ethereum (mainnet/ropsten/rinkeby/goerli)

Environment (Other)

No response

mateja176 avatar May 20 '24 10:05 mateja176

This is possibly an xdefi browser wallet bug given that the tx.input aka tx.data is failing the isHexString check because it doesn't start with 0x. Can you confirm this assumption @ricmoo?

mateja176 avatar May 20 '24 14:05 mateja176

hi, how is going about the question?

Endund avatar Jun 01 '25 13:06 Endund