Pending on Polygon


I’m using a cloud function that uses an ethersjs cloudfactory to deploy contracts on Polygon using the ethersjs and provider from:

const allEthers = Moralis.ethersByChain(‘0x89’);

I create a signing wallet with:

const wallet = new ethers.Wallet(privateKey, provider);

Everything appears to work fine and I get a contract address and transaction hash. TH shows Pending for a very long time, perhaps forever " This txn hash was found in our secondary node and should be picked up by our indexer in a short while."

I’m not clear on how to get these moving. How frequently are they picked up? How can they be picked up quicker? Note that I’ve tried changing gas options but don’t see any difference. Yes, I understand the risks. Thanks!

Can we see your contract deploy code and how you’re setting gas. Was this 0xa1455225154b13b1809f653a6364b2de03e5a850 address generated from new ethers.Wallet?

=Trying to wait for contract fails. Yes, it was generated from a new ethers.Wallet.

        const allEthers = Moralis.ethersByChain(chainId);
        const ethers = allEthers.ethers;
        const provider = allEthers.provider;
        const wallet = new ethers.Wallet(privateKey, provider);

        const factory = await new ethers.ContractFactory(abi, bytecode, wallet);     
        const incPrice = await provider.getGasPrice() * 3;
        const price = ethers.utils.formatUnits(incPrice, 'gwei');
        const options = {nonce: 95847, gasLimit: 10000000, gasPrice: ethers.utils.parseUnits(price, 'gwei')}

          let contract = await factory.deploy(contractName, contractSymbol, options);
          let contractAddress = await contract.address;  
          let contractDt = await contract.deployTransaction;

Any reason why you’re setting the nonce manually? For gasPrice, try setting it directly

const incPrice = await provider.getGasPrice();
const options = { gasPrice: incPrice, ... };

and without the nonce.

I tried with and without. That’s me reaching for anything.

Try using another RPC for the provider. Also have you tried deploying your same contract in another environment e.g. in Remix or a local project? If that doesn’t work, you can post your ABI and bytecode.

Any advice you can provide would be eternally appreciated! I’m new to solidity. It feels like my gas options are ignored.

Wiscle ABI
Wiscle Bytecode

You can try to set manually a value for the gas price, don’t try to set the nonce, maybe it will set it automatically to the right value. The nonce thallus be close to the number of transactions that are already on chain for that wallet address.

Thanks for the help!

I woke up to my transaction finally getting processed:

What does the huge delay mean, please? Is “pending” a gas problem? Or is there a delay that I cannot control between the time the contract is deployed in a cloud function and the time it is picked up by Polygon?



it could be a delay because of low gas price if there are a lot of transactions waiting to be processed on that specific network

So it seems.

Thanks for your help!

1 Like

Hi @pvermont!
I had the same problem yesterday. All tx was pending and didn’t receive confirmation. I am using mumbai. And I try using ethersJS from Moralis and using Moralis.executeFunction(). All times I saw tx without confirmation and the message: “This txn hash was found in our secondary node and should be picked up by our indexer in a short while.”. And suddenly, in the night, all tx was confirmed.
And from the mumbai scan it doesn’t happen: the txn is confirmed quickly.
I don’t idea why ocurre this problem.

1 Like

This happened to me again over the weekend on polygon mainnet.
Today, transactions are almost instantaneous.
Increasing gas has no effect in determining “when” polygon sees our transactions Can someone share the algo for when polygon decides to pick up our transactions?
It might be an hour or many hours but eventually the transactions are processed all at once

Same account on Metamask is processed immediately even when secondary chain is in pending.

I’d like to know how this works through Moralis, please.

You can use a custom RPC url in cloud code if you think that it will work better compared to our RPC node. You can use the same RPC url that you have in MetaMask for example.

You can also try to compare the transactions to see if it is anything different on them. All the information should be available in polygon scan about them.

1 Like

If I must. I was hoping it was a known situation and Moralis might have some tips that could save me from having to do it. I’ll admit I’m not an expert on this subject.

Overall, I’m getting what I need from Moralis and will investigate the “pending” lag when time permits and when I see it again.


1 Like