0

I am trying to sign a manual transaction using ethereumjs-tx to interact with a smart contract.

This is how I am getting my gaslimit, nounce and data for the params

 var GAS = await cont.methods.withdraw("100000000000000000").estimateGas({from: address}, 
 function(error, estimatedGas) {
      console.log(estimatedGas);
    });
    console.log("gas limit is"+GAS);

    var nonce = await web3.eth.getTransactionCount(address);
    console.log(nonce);

    var hexData = await cont.methods.withdraw("100000000000000000").encodeABI();
    console.log(hexData);

And this is how I am declaring the params for ethTx object :

  const params = {
            nonce: nonce,
            to: contractAddress, //address of the receiver
            value: '0x000', // value in hexa format
            gasPrice: web3.utils.toHex('100'),
            gasLimit: GAS,
            chainId: 42, // 1 for main ethereum chain
            data: hexData
          };

This is the txHash for the code after running the script txhash.

I am not sure what I am doing wrong. Please help me get into the right path. Thanks!

1 Answer 1

0

Even tho it shouldn't matter because it's a test net, they may not like such a low gas price of 0.0000001 Gwei. Try to replace the transaction by sending a higher gas price, maybe at least 1 Gwei

2
  • So doesn't web3.utils.toHex('100') means 100 Gwei?? Feb 25, 2021 at 10:06
  • 1
    It means 100 wei, which is 0.0000001 Gwei, which is 0.0000000000000001 ETH. You can convert them here: eth-converter.com
    – 3DLures
    Feb 25, 2021 at 10:28

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.