[SOLVED] Transaction not mined within 50 blocks error

Hi, I am using the web3.js library to deploy a smart contract giving it some parameters and setting also the eth value that would be sent in the smartcontract.

Using a 0.4v Solidity version smart contract it works just fine. But when using a smartcontract of version 0.5 of solidity it gives me the following error:
" Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!"

The main difference between both versions is that in the 0.4v, the input arguments are inside a function and in the 0.5v they are inside the constructor. Apart from this I can not seem to find any differences between both versions.

Below i attach JS code I am using from web3.js library. I am changing the ABI and bytecode when changing smart contracts. Apart from that, everything remains the same. Checking on Internet I have been recommended to increase by a lot the gas fee which I have done (paying almost 1 tBNB) but the error remains there. I know that the smartcontract works perfectly as I have been able to deploy it using Remix, but i do not know why it is not working with web3js.

This is the smartcontract I am using: https://testnet.bscscan.com/address/0x9124673dd5665a8db86513bbbd430a4886924089#code

Can someone please tell me what may be happening? Thank you, I have been stuck with this error for some weeks.

var standardtokenContract = new web3.eth.Contract(abi);
 standardtokenContract.deploy({ 
            data: '0x' + bytecode,
            arguments: [$tokenName, $tokenSymbol, $decimalUnits, $initialSupply,address] 
            }).send({ 
            from: addressU,
            value:ethers.utils.parseEther("0.005")
            //  gas: "1000000",
            //gasPrice: '30000000000'
           )]

I also have a an error handling part of the code which I have not included por simplicity purposes.

https://testnet.bscscan.com/address/0x9124673dd5665a8db86513bbbd430a4886924089#code

This is the contract you deployed when you got the transaction not mined error? What is the RPC URL you are using for web3.js provider? Or are you just your wallet as the provider - the same one when deploying with Remix?

Try increasing gasLimit:

.send({
      gasLimit: 4000000,
      ...
   })

I mean I first deployed the contract through Remix and verifying it on the scan. Then I am using its ABI and bytecode through web3.js to programatically create new tokens based on this smart contract, just changing the parameters.

Regarding the RPC Url, right now I am trying on Bsc Testnet (https://data-seed-prebsc-1-s1.binance.org:8545/) and Mumbai Polygon (https://rpc-mumbai.maticvigil.com/).

I have tried increasing the gasLimit as you suggested but keep getting the same error.

Any idea why this may happen? I am stuck and do notm know how to proceed.

Thank you and best regards

I am not sure of the cause of the error - the general workaround seems to be setting higher gas so the transaction gets priority.

Which version of web3.js are you using? I was able to deploy a contract with your code (copying ABI and bytecode from that BSC testnet contract) using my MetaMask wallet (with same BSC testnet RPC URL).

Can you try hardcoding your parameters e.g. arguments, from address.

Hi, I have tried hardcoding parameters and keep getting the same error.

I am using 1.8v of web3js. I am able to deploy the contract using Remix, but it does not work when I do it programatically using web3js. If you have a web3js code that works for you could you please copy and paste it for me so that i have it exactly as yours. I have tried to set higher gas, so do not know why it is not working.

Thank you and best regards

I am using web3.js 1.7.5. It is your code more or less:

const bscAbi = .. // from 0x9124673dd5665a8db86513bbbd430a4886924089
const bytecode = ... // from 0x9124673dd5665a8db86513bbbd430a4886924089

var standardtokenContract = new web3.eth.Contract(bscAbi);
    standardtokenContract
      .deploy({
        data: '0x' + bytecode,
        arguments: [
          'test',
          'test',
          '18',
          '100',
          '0xF45ca69E1c545E33180e349A5c75D68835a7E635',
        ],
      })
      .send({
        from: '0xF45ca69E1c545E33180e349A5c75D68835a7E635',
        value: Moralis.Units.ETH('0.005'),
        //  gas: "1000000",
        //gasPrice: '30000000000'
      });

Okey so I have copied your code and tried and keep getting the error. Then I changed the web3js to 1.7.5v. With this version I keep getting the “transaction not mined in 50 blocks error”, but when raising the gas fees I get now this new error:
" {code: -32603, message: `[ethjs-query] while formatting outputs from RPC '{…her) exceeds the configured cap (1.00 ether)}"

Still stuck here, would really appreciate some help. Thank youu!!

Can you post your full code including how you set your web3 provider (with web3.js)?

Consider any differences between your environment and mine e.g. wallet address (make sure you have enough currency), wallet (I used MetaMask extension) on BSC testnet (https://data-seed-prebsc-1-s1.binance.org:8545/).

If you still have trouble, I can deploy a demo for you to try.

Otherwise try using ethers.js instead.

Okey so I am using web3js in browser (no npm or yarn), I don’t know if this may affect.

I am importing it on my index.html file like this:

<script src="https://cdn.jsdelivr.net/gh/ethereum/[email protected]/dist/web3.min.js"></script>

And in my main.js I am setting my provider like this:

const web3 = new Web3(window.ethereum);

Regarding the other issues, I do have enough currency and I am also using Metamask.

Can you try this demo - you will need to manually connect the site first to your MetaMask wallet. The code is available in page source.

Perfect I will try that now. Where have to attached the demo, I can not find it. I do not know what you mean with page source, I can not find it.

Once again I am extremely grateful for your help, but I do not know where to finde the demo

Sorry I forgot to link it. The demo is here.

It is finally working!! I am extremely grateful! If you can share with me your eth address I would love to give you a tip once my project starts giving me profit.

I still have one doubt though. I had exactly the same code, so the only explanation I have for this is that I must have had the wrong ABI or bytecode.

Could you please explain with a screenshot form the scan or something were exactly you took the ABI and bytecode from?

Once again, thank you!

1 Like

I copied both the ABI and bytecode from that contract page using the copy buttons.

Hi, checking the transaction and contract created I noticed that the contract is deploying succesfully but the contructor arguments (name, symbol, decimals, supply, and receiving address of value) are not being updated.

So using your demo instead of getting a token named “test”, with 18 decimals I am getting a token with the preconfigured values set in the smartcontract (in this case a token named “Wevelop”, symbol “WEV” and 10 decimals).

If you check the deployed contract you sent me on the message I am reponding to, you can see that this exactly happened to you too. So this means that the arguments set in the web3js are not interacting and updating the constructor arguments of the smart contract. Do you know why this may be happening?

Once again, extremely grateful for your help! Hope you can solve this too.

Yes I noticed that. To be clear, this was your code that now deploys successfully. I am not sure why it isn’t updating, maybe an issue with the contract - does it work with Remix? You can do some tests.

Okey I will try and so some tests? Do you have any suggestions of things that I should try or hints of why this may be happening?

Passing arguments works fine when deployed with Remix so it may be an issue with the code. I was not able to get it working with a few things I tried - it also did not work when I tried deploying with ethers.js. By tests, I mean trying different things.