Transaction underpriced

Hey guys,

I’ve like to know if anyone can relate to this… I’m getting this two erros and can’t get my bot to work

Error: Returned error: replacement transaction underpriced
or
Error: Returned error: transaction underpriced

Bellow is my code

async function buyNFT(informations, transaction) {
    let nonce = await web3.eth.getTransactionCount(account.address)
    console.log('nonce: ',nonce)
    let tx = {
        // this could be provider.addresses[0] if it exists
        from: account.address,
        // target address, this could be a smart contract address
        to: contractAddressBid,
        // optional if you want to specify the gas limit
        gas: 300000,
        gasPrice: '5000000000',
        nonce: nonce + 1,
        // optional if you are invoking say a payable function
        // value: informations.price,
        // this encodes the ABI of the method and the arguements
        data: contractBid.methods.bid(informations.pvu_token_id, informations.price).encodeABI()
    };
    const signPromise = web3.eth.accounts.signTransaction(tx, privateKeyAccountBid);

    signPromise.then((signedTx) => {
        // raw transaction string may be available in .raw or
        // .rawTransaction depending on which signTransaction
        // function was called
        let sentTx = web3.eth.sendSignedTransaction(signedTx.rawTransaction);
        sentTx.on("receipt", receipt => {
            console.log('SUCCESS BUY')
        });
        sentTx.on("error", err => {
            console.log('error BID:', err)
        });
    }).catch((err) => {
        console.log('error sign promise:', err)
    });
}

async function sellNFT(informations) {
    let timeStampUTCNow = ((new Date((new Date(new Date().setDate(new Date().getDate() + 1000))).toUTCString())).getTime()) / 1000
    contractReadAndSellAuction.methods.createSaleAuction(
        informations.pvu_token_id,
        informations.reseller_price,
        informations.reseller_price,
        timeStampUTCNow
    ).send({
        from: web3.eth.defaultAccount,
        gas: 300000,
        gasPrice: '5000000000'
    }).then(function (result) {
        console.log('SUCCESS SELL: ', result)
    }).catch(function (err) {
        console.log('error SELL: ', err)
    });
}

Anyone could help me out?

maybe it is not enough gas(300000) for those transactions that you want to do

Already tried that. No success.

Were you able to fix it? I am experiencing a similar problem.

on what network you try to make that transaction? asking because the gas price of 5 GWEI may work on Binance chain but maybe not on other networks.

Yes, I am using binance. I’m kind of new at this I may not be doing something right. In short this is what I do:

I use hdwallet-provider with a getblock url and the mnemonic.
I enter the provider to web3.

And I use the private key and the address as in the example above. However I still get this error.

Basically what I want is to make transactions with an existing wallet in the binance network.