Shihab Shahriyar
Shihab Shahriyar

Reputation: 37

Thirdweb error: Transaction was not mined within 50 blocks error

So I have this code:

import { ThirdwebSDK } from "@thirdweb-dev/sdk";
import { ConnectWallet, useAddress } from "@thirdweb-dev/react";

export default function DonationPage() {
    let address = useAddress()

     async function sendCoins() {
        try {
            let random = ethers.Wallet.createRandom();
        // get a signer from somewhere (createRandom is being used purely for example purposes)
        // get an instance of the SDK with the signer already setup
        const sdk = ThirdwebSDK.fromSigner(signer || random, "mainnet");
        try {
            if (selectedCoin == 'eth') {
                await sdk.wallet.transfer(CORPORATE_WALLET || "0x", donationAmount);
            } else {
                // const decimals = await contract.erc20..call()
                // const amount = new BigNumber(donationAmount * (10 ** decimals))
                const contract = await sdk.getContract(crypto.find((coin) => coin.id == selectedCoin)?.contract_address || '0x');

                let balance = await contract.erc20.balance()
                let allowance = await contract.erc20.allowance(address || '0x')

                // console.log('balance', balance.value)
                // console.log('allowance', allowance.value)

                if(donationAmount + Number(balance.displayValue) > Number(allowance.displayValue)) {
                    await contract.erc20.setAllowance(address || '0x', donationAmount + Number(balance.displayValue))
                }
                await contract.erc20.transferFrom(address || '0x',CORPORATE_WALLET || '0x', donationAmount);

            }
        } catch (error: any) {
            alert(error.message)
        }
    }

    return (<>...</>)

}


So i'm using ConnectWallet button to get address and using TrustWallet for this, and trying to transfer tokens from 'address' to a corporate wallet, with a specified donation amount.

However, I receive this error "Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined".

There seems to be no documentation on this online, and ChatGPT won't help either. Does someone know how to fix this?

Upvotes: 0

Views: 340

Answers (1)

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83438

  • You can pull up the transaction by its hash on EtherScan and check what the estimation time is for the transaction to be included in a block by a block producer

  • Because there are no details on the transaction on the question itself, it is not possible to give more specific answer

  • For transaction troubleshooting, please refer to ethereum.stackexchange.com as diagnosing transaction failures is not really related to programming

Upvotes: 0

Related Questions