I'm trying to sign data offline and then send signed transaction via web3.js

Here's my code snippet:

const {sign} = require('@warren-bank/ethereumjs-tx-sign');
const {Loader} = require("loader-in-console");

var txData = {
    nonce: nonce,
    chainId: 80001,
    from: address1,
    to: address2,
    data: data,
    gas: 30000,
    gasPrice: 35000,
    value: '0x0'

const {rawTx} = sign(txData, privateKey);
var serializedTx = '0x' + rawTx.toString('hex');

let txResponse = await web3.eth.sendSignedTransaction(serializedTx);

It's timing out. What am I doing wrong here and is there an alternate way to do it?

1 Answer 1


Your gas price is extremely low. You can query the gas price with web3.eth.gasPrice(), when I did this I got 2000000000. As your 35000 is very low it will take a long time (or potentially never) for a miner to pick up this transaction.

  • I'm using polygon testnet. mumbai.polygonscan.com
    – Ani
    Jan 4, 2022 at 10:27
  • You gasPrice is too low even for Polygon testnet. if this is too low the nodes will not pick your transaction. E.g. if you look at mumbai.polygonscan.com/tx/… you see that the gas price is 250Gwei, which is way higher than what you set ;)
    – Richard
    Jan 4, 2022 at 12:46
  • When I use that gas, I get Error: Returned error: tx fee (500.00 ether) exceeds the configured cap (1.00 ether)
    – Ani
    Jan 5, 2022 at 5:22
  • You need to set a reasonable limit. According to the error you used 500 Ether, you should use a fraction of this. If you want to hardcode it use gasPrice: 200_000_000_000. But as mentioned before, the recommended way is to call await web3.eth.gasPrice() to get the value.
    – Richard
    Jan 5, 2022 at 8:28
  • Yeah I'm setting whatever response await web3.eth.gasPrice() gets me.
    – Ani
    Jan 5, 2022 at 8:31

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.