Skip to content
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

invalid value for value.data (invalid data (argument="value", value="", code=INVALID_ARGUMENT, version=6.13.1)) #4853

Open
ArchTaqi opened this issue Oct 7, 2024 · 2 comments
Assignees
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6

Comments

@ArchTaqi
Copy link

ArchTaqi commented Oct 7, 2024

Ethers Version

6.13.1

Search Terms

No response

Describe the Problem

Encountering issue sending ETH between wallets via code, despite transaction success on Etherscan and wallet verification. Error prevents cascading transactions, which rely on this initial transaction's positive response. Tried various RPC providers without resolution. Seeking assistance to identify error source.

Code Snippet

const ethers = require('ethers');

const providerUrl = 'quick-node-mainnet-rpc';
const hot_wallet_privateKey ='';
const provider = new ethers.JsonRpcProvider(providerUrl);
const wallet = new ethers.Wallet(hot_wallet_privateKey, provider);


const nonce = async () => {
    const nonce = await wallet.getNonce();
    console.log(nonce);
    const recipientAddress = '0x95FD6074659D4aC99Fd7B5D5cae6afAcFb211a07';
    const amountToSend = ethers.parseEther('0.001'); // 0.1 ETH

    const transaction = {
        to: recipientAddress,
        value: amountToSend,
        nonce:nonce,
    };

    const test = async () => {
        const tx = await wallet.sendTransaction(transaction);
        await tx.wait(1);
        console.log('Transaction sent:', tx.hash);
    };

    try { test(); } catch (error) {
    console.error('Error sending transaction:', error);
    }
};
nonce();

Contract ABI

No response

Errors

Error: invalid value for value.data (invalid data (argument="value", value="", code=INVALID_ARGUMENT, version=6.13.1)) (value={ "accessList": [  ], "blockHash": null, "blockNumber": null, "chainId": "0x1", "from": "0x2B4E3Df272E05b5318C69C95274055973C36fE1D", "gas": "0x5208", "gasPrice": "0x77850d4a0", "hash": "0x9772deb5d7f3969ed4dd62a198c674e3a2b14d1517fef84e47cde962ed5eb9a3", "input": "", "maxFeePerGas": "0x77850d4a0", "maxPriorityFeePerGas": "0xf4240", "nonce": "0x66", "r": "0x0", "s": "0x0", "to": "0x95FD6074659D4aC99Fd7B5D5cae6afAcFb211a07", "transactionIndex": null, "type": "0x2", "v": "0x0", "value": "0x38d7ea4c68000" }, code=BAD_DATA, version=6.13.1)
    at makeError (/Users/muhammadtaqi/Projects/Backend/node_modules/ethers/lib.commonjs/utils/errors.js:129:21)
    at assert (/Users/muhammadtaqi/Projects/Backend/node_modules/ethers/lib.commonjs/utils/errors.js:149:15)
    at /Users/muhammadtaqi/Projects/Backend/node_modules/ethers/lib.commonjs/providers/format.js:57:39
    at formatTransactionResponse (/Users/muhammadtaqi/Projects/Backend/node_modules/ethers/lib.commonjs/providers/format.js:225:7)
    at JsonRpcProvider._wrapTransactionResponse (/Users/muhammadtaqi/Projects/Backend/node_modules/ethers/lib.commonjs/providers/abstract-provider.js:348:96)
    at JsonRpcProvider.getTransaction (/Users/muhammadtaqi/Projects/Backend/node_modules/ethers/lib.commonjs/providers/abstract-provider.js:782:21)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async checkReplacement (/Users/muhammadtaqi/Projects/Backend/node_modules/ethers/lib.commonjs/providers/provider.js:1058:27)
    at async TransactionResponse.wait (/Users/muhammadtaqi/Projects/Backend/node_modules/ethers/lib.commonjs/providers/provider.js:1152:13)
    at async test (/Users/muhammadtaqi/Projects/Backend/native-test.js:27:3) {
  code: 'BAD_DATA',
  value: {
    blockHash: null,
    blockNumber: null,
    from: '0x2B4E3Df272E05b5318C69C95274055973C36fE1D',
    gas: '0x5208',
    gasPrice: '0x77850d4a0',
    maxFeePerGas: '0x77850d4a0',
    maxPriorityFeePerGas: '0xf4240',
    hash: '0x9772deb5d7f3969ed4dd62a198c674e3a2b14d1517fef84e47cde962ed5eb9a3',
    input: '',
    nonce: '0x66',
    to: '0x95FD6074659D4aC99Fd7B5D5cae6afAcFb211a07',
    transactionIndex: null,
    value: '0x38d7ea4c68000',
    type: '0x2',
    accessList: [],
    chainId: '0x1',
    v: '0x0',
    r: '0x0',
    s: '0x0'
  },
  shortMessage: 'invalid value for value.data (invalid data (argument="value", value="", code=INVALID_ARGUMENT, version=6.13.1))'
}

Node.js v20.17.0

Environment

Ethereum (mainnet/ropsten/rinkeby/goerli)

Environment (Other)

No response

@ArchTaqi ArchTaqi added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Oct 7, 2024
@usman-codora
Copy link

Following

@jasonandjay
Copy link

Obviously your data format is incorrect. You expect a hexadecimal string, but you provide an empty string. I believe this problem can be solved by switching nodes.

Maybe you can consider compatibility with empty strings, but that is a future plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

4 participants