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?