Infura do not send signed transaction to the ETH mainnet network

Hi. my ether wallet test web3 version 1.2.11.
but do not sendSignedTrasaction function.

error message is ‘Error: Transaction was not mined within750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!’

signed raw transaction body
0xf86e827b7d850df8475800830186a094d760dc10f70ade6dfa1b012b28eda7acceeee893871550f7dca70000801ba00b0b14b1d91ac80d538d21ea1aff477e0240942d394e26f5a27aeaa7e9ca2b33a066105a744a715608540d9a981e8da1b596e4ea0e5360fb496b499ed00160987c

can you help me?

thank you

Hi @hsson - welcome to the Infura community! If your transaction was not mined within 750 seconds, I would suggest increasing the gas price. If that doesn’t work, please let us know and we can help you figure out what’s going on.

@Leiya_Kenney

I am grateful for your kindness.

This is my code sample.
Still I haven’t found a workaround. What is wrong?


let Web3Ex = function() {
this.setProvider(new this.providers.HttpProvider(global.config.ETH.host));

this.GAS_PRICE = this.utils.toWei( '60', 'gwei');
this.GAS_LIMIT = 100000;
this.TRANSACTION_FEE_WEI = (this.GAS_LIMIT * this.GAS_PRICE);
this.last_nonce = 0;
global.config.ETH.web3ex = this;
return this;

};

sendfee: async function( resp, addr, callback ) {
let FeeWalletAddr= this.hdwallet.feewallet_addr;
let FeeWalletPK = this.hdwallet.feewallet_pk;
let sender = this;

    let web = new web3();
    global.config.ETH.web3ex = web.setProvider(new web.providers.HttpProvider(global.config.ETH.host));


    let remain = this.web3ex.eth.getBalance(addr);
    let remain_fee = this.web3ex.eth.getBalance(FeeWalletAddr);

    if(remain_fee <= 0 ) {
        resp.send(_make_error_ret({ value: remain_fee, msg: 'Fee Account balance is insufficiant. (current amount : ' + remain_fee + ')'}, 'error'));
        return
    }

    if(remain >= this.web3ex.TRANSACTION_FEE_WEI ) {
        return
    }

    let nonce = this.web3ex.eth.getTransactionCount(FeeWalletAddr, 'pending');
    let gasPrice = this.web3ex.GAS_PRICE;
    let gasLimit = this.web3ex.GAS_LIMIT;

    let amount = this.web3ex.TRANSACTION_FEE_WEI;

    const params = {
        nonce: this.web3ex.utils.toHex(nonce),
        // nonce: this.web3ex.utils.toHex(10),
        from: FeeWalletAddr.toLowerCase(),
        to: addr.toLowerCase(),
        value: this.web3ex.utils.toHex(amount),
        gasPrice: this.web3ex.utils.toHex(gasPrice),
        gasLimit: this.web3ex.utils.toHex(gasLimit),
    };

    const tx = new ethTx( params, {chain: 'mainnet', hardfork: 'constantinople'} );

    let pkBuffer = new Buffer(FeeWalletPK, "hex");
    tx.sign(pkBuffer);

    const serializedTx = tx.serialize();
    const txData = `0x${serializedTx.toString('hex')}`;
    params.tx = txData;
    console.log( params )

    // callback( { success: true, txid: txData, params: params} )
    this.web3ex.eth.sendSignedTransaction(txData)
    .on('transactionHash', (hash) => {
        console.log( hash )
    })
    .on('receipt', (txid) => {
        let result = { error: false, txid: txid, params: params }
        callback(result)
    })
    .on('error', (error) => {
        let result = { error: true, msg: error, params: params }
        callback( result )
    });
},

It looks like you have 60 gwei as your gas price. According to ethgasstation.info, recommended gas prices are much higher, closer to 90 gwei. I would suggest increasing your gas price closer to that and seeing if it gets mined.

@hsson, @Leiya_Kenney is saying right, its not good to hardcode the the Gas price, Web3 offer functions to fetch current network Gas price.

Please reffer to this link: https://web3js.readthedocs.io/en/v1.2.0/web3-eth.html#getgasprice

1 Like

I’ve been running into the same issue using rinkeby (HTTPS/WSS).

require('dotenv').config();
const HDWalletProvider = require('@truffle/hdwallet-provider');
const Web3 = require('web3');
const abi = require('./compile').abi;
const bytecode = require('./compile').evm.bytecode.object;

const provider = new HDWalletProvider(process.env.SEED_PHRASE, process.env.INFURA_API_KEY);
const web3 = new Web3(provider);

const deploy = async () => {
  const accounts = await web3.eth.getAccounts();
  console.log('Attempting to deploy from account', accounts[0]);

  let limit = await web3.eth.getGasPrice().then(x => { return x })

  const result = await new web3.eth.Contract(abi)
    .deploy({ data: bytecode, arguments: ['Hello World'] })
    .send({ gas: 2000000, gasPrice: limit, from: accounts[0] });
  
  console.log('Contract deployed to: ', result.options.address);
};

deploy();

Would anyone be able to point me in the right direction?

Hey @ar4s, and welcome to the Infura community!

You may be running into web3's default transactionPollingTimeout, which is 750 seconds (if you want to learn more about that, you can read the docs here). This is used only with web3's HTTP provider, however, so if it’s possible you can try using a websocket provider to avoid the timeout. This issue on the Truffle GitHub may give you some additional context if you want to try that out!

A couple of other easy first troubleshooting measures would be to make sure you’re using the correct nonce number and just double check that the gas price you’re sending is neither too low or too high!

If you’re still running into issues, let us know and we’ll dig further :slight_smile: