Transaction was not mined within 50 blocks

const axios = require('axios');                     //used for getting api data, install with "yarn add axios"
const Web3 = require('web3');                       //used for web3 functions, install with "yarn add web3"
const Common = require('ethereumjs-common').default;//used for creating custom chains, install with "yarn add '@ethereumjs/common@v2.2.0'"
let Tx = require('ethereumjs-tx').Transaction;

let ETHprovider = new Web3.providers.WebsocketProvider('wss://')
let web3 = new Web3(ETHprovider);
let privateKey = Buffer.from('PRIVATE_KEY', 'hex');
const ADDRESS = 'ADDRESS';//your address
let callURL = '' +
    'toTokenAddress=0x27f8d03b3a2196956ed754badc28d73be8830a6e&' +
    'amount=10000000000000000000&fromAddress=' +
let approveURL = '';

const ethereumMainnet = { 'chain': 'mainnet' }
async function driver() {
    globalData = await approveApiCaller(approveURL, 10000000000000000000, "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063", "0xfe");
    console.log('Global Data done')
    transaction = signTx(globalData);               //sign the transaction with 
    console.log(transaction);                       //print the serialized transaction
    console.log('Sign global data')
    sendTransaction(transaction);                   //send the transaction
    console.log('Send Transaction')
    globalData = await apiCaller(callURL, '0xff');  //call the api to get the data, and wait until it returns
    console.log(globalData["tx"]);                  //log the data
    transaction = signTx(globalData["tx"]);         //sign the transaction
    console.log('send transaction');
    sendTransaction(transaction);                   //send the transaction
    console.log("transaction success");

 * Sends a transaction based on serialized data
 * @param {the serialized transaction you want to send} tx 
function sendTransaction(tx) {
    let temp = '0x' + tx.toString('hex');           //make the transaction into a hexadecimal string
    .on('transactionHash', async function(hash){
        const status = await waitTransaction(hash);
    .on('receipt', function(receipt){
    .on('confirmation', function(confirmationNumber, receipt){ 
    .on('error', function(error, receipt) {
    }); // If a out of gas error, the second parameter is the receipt.
 * Will sign a transaction with a private key based on the transaction data provided
 * @param {the transaction you'd like signed} tx
 * @returns serialized transaction
function signTx(tx) {
    let temp = new Tx(tx, ethereumMainnet);
    //let temp = new Tx(tx, { common: ethereumMainnet });
    return temp.serialize();
 * This will call the api to get an approve transaction, some tokens need to be approved to 0 before increasing again later
 * @param {the url used to access the } url 
 * @param {the number of tokens that are requested to be unlocked, if "null" infinite will be unlocked } value 
 * @param {the token address of what tokens needs to be unlocked} tokenAddress
 * @param {the nonce of the transaction} nonce
 * @returns approve transaction
async function approveApiCaller(url, value, tokenAddress, nonce) {
    url += (value > -1 || value != null ? "?amount=" + value + "&" : "") //tack on the value if it's greater than -1
        + "tokenAddress=" + tokenAddress             //complete the called URL
    let temp = await axios.get(url);                //wait for the request to be complete

    temp =;                               //we only want the data object from the api call
    //we need to convert the gas price to hex
    let gasPrice = parseInt(temp["gasPrice"]);
    gasPrice = '0x' + gasPrice.toString(16);        //convert to hexadecimal string
    temp["value"] = "0x" + temp["value"];           //convert value to hecadecimal
    temp["gasPrice"] = gasPrice;                    //change the gas price in the tx object
    temp["gas"] = "0xc350";                         //gas limit of 50,000, may need to be higher for certain tokens
    temp["from"] = ADDRESS;
    temp["nonce"] = nonce;

    return temp;

 * Will call the api and return the data needed
 * @param {the url of what api call you want} url 
 * @param {the nonce of the transaction, the user must keep track of this} nonce
 * @returns swap transaction
async function apiCaller(url, nonce) {
    let temp = await axios.get(url);                //get the api call
    temp =;                               //we only want the data object from the api call
    //we need to convert the gasPrice to hex
    let gasPrice = parseInt(temp.tx["gasPrice"]);   //get the gasPrice from the tx
    gasPrice = '0x' + gasPrice.toString(16);        //add a leading 0x after converting from decimal to hexadecimal
    temp.tx["gasPrice"] = gasPrice;                 //set the value of gasPrice in the transaction object
    //we also need value in the form of hex
    let value = parseInt(temp.tx["value"]);			    //get the value from the transaction
    value = '0x' + value.toString(16);				      //add a leading 0x after converting from decimal to hexadecimal
    temp.tx["value"] = value;						            //set the value of value in the transaction object
    temp.tx["nonce"] = nonce;  
    console.log(temp);    //it's the users responsibility to keep track of the nonce
    return temp;                                    //return the data

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));

async function waitTransaction(txHash) {
    let tx = null;
    while (tx == null) {
        tx = await web3.eth.getTransactionReceipt(txHash);
        await sleep(2000);
    console.log("Transaction " + txHash + " was mined.");
    return (tx.status);

Sorry guys, I needed some help badly. With the provided code, I am getting Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined! Sometime I get transaction underpriced. Can someone help me on this issue?

Hi @owsome888, and welcome to the Infura community! From the error message, it sounds like you may need to try increasing your gas price - have you tried that already?

Thank you Leiya for your very kind word.
I am using 1Inch official gas price, may I know what’s the best way to set the gas price?

I tried to increase the gas price 10 fold and having the same problem. My transaction hash is 0xe46966e4dc76f539ae0255c6aa617aca0901e53da1f5028e5f9b1f4a4166978d

1 Like

Thanks for providing the transaction hash!

It’s interesting - in our system, it says that you tried sending this 5 different times - the first and second tries, your transaction was underpriced, but the third, fourth, and fifth times, it looks like it went through with the following result: {“jsonrpc”:“2.0”,“id”:2,“result”:“0xe46966e4dc76f539ae0255c6aa617aca0901e53da1f5028e5f9b1f4a4166978d”}

I am facing this problem for 2 days now, and I have also tried many times by increasing the gas charge, but all get the same message as above. Please help me fix this problem. Thank you very much and look forward to your help.
Dây là băm giao dịch của tôi : 0xba19931f8d9f3caa2512f32dc7f0f4de9fd912d6e70242ab73eb730308f5dea5

Hi @Ngoc_Sy, and welcome to the Infura community!

I am not seeing your transaction hash in our database - can you please send over the code you’re using to try to send the transaction so we can help you debug?

hello i’ve been getting this error for 2 days now. what should I do. I’ve raised the gas price a lot, but I still haven’t figured it out. (Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!)

Hello, I’m having the same problem.

“Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!”

Raised gas price but still haven’t solved the problem. Any tips for solving this issue?

Hello @Bruno_Lima, @playcards100, and welcome to the Infura community!

Would you be able to share transaction hashes with us so we can take a look?

Hello, I have the same probjem. transaction hash is 0x23cc9b834bd2b2d752885a1d2c1e0c198a5b30822292e749d0f2253e64d5bf09.
I’m using web3j, here is the code:

BigInteger gasLimit = BigInteger.valueOf(5000000);
BigInteger gasPrice = Convert.toWei(“1”, Convert.Unit.GWEI).toBigInteger();
ContractGasProvider gasProvider = new StaticGasProvider(gasPrice, gasLimit);
var contract = Erc20.load(“0x72d8513987bc89afd51d20490bdf2cc7f6ae8b12”, web3j, credentials, gasProvider);
var result = contract.approve(“0xA67E0B126E5bCe25551Dc0B3211A1Bd0F4674e0B”, BigInteger.TEN).send();

The problem was in gas limit. Sorry to bother you.

1 Like

@stomchuk, I’m glad you were able to figure it out, and thanks for letting us know!


I have the same problem, I have Harmony ONE coins and I receive the same message when I want to claim rewards or send some coins for someone, My message is as below.

Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!

anybody can help me, unfortunately, no hash exists on to share with you

I set the Gas price GWEI ( 30 ) and the Gas Limit ( 21000 )