Deploy to Polygon/Matic Mumbai Fails

Hey Team,

I setup a Polygon test account and used the faucet to get ETH - only sends 0.1 ETH.

Tried to deploy a contract to Mumbai using the Moralis RPC endpoint in truffle and the deploy failed with:

Starting migrations…

Network name: ‘matic’
Network id: 80001
Block gas limit: 20000000 (0x1312d00)

1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------

Error:  *** Deployment Failed ***

"Migrations" could not deploy due to insufficient funds
   * Account:  0x5bE9bca32BfD527B40d82c6a2B2A9c7246027BFc
   * Balance:  100000000000000000 wei
   * Message:  insufficient funds for gas * price + value
   * Try:
      + Using an adequately funded account
      + If you are using a local Geth node, verify that your node is synced.

The account and balance match the test account I created.

So on a whim I used Remix to deploy on to Ropsten. Deployment succeeded, cost 0.0044 ETH.

Total gas used for all contracts deployed: 4,400,262 (using gas station on mainnet this looks like a current cost of 0.0440026 ETH).

I have not used truffle to deploy to any network other than GANACHE. In the past if I deployed to Ropsten or Mainnet I used Remix.

Since the amount in my Mumbai account is greater than what deployment to mainnet would cost, I assume something is wrong with my truffle deployment setup.

Here is the entry in the truffle.config file:


     matic: {
       provider: () => new HDWalletProvider(secretKey, `https://speedy-nodes-nyc.moralis.io/a919256c3780769ae58d0149/polygon/mumbai`),
       network_id: 80001,
       confirmations: 2,
       timeoutBlocks: 200,
       skipDryRun: true
     },

What other information can I provide that would help? Any thoughts?

Thank you,

David

1 Like

Hey @dbgoodrich, hope you are ok.

Would be great if you can provide a github repo so i can try to replicate the same issue, no need for a rinkeby secret key, i will use mine.

Carlos Z

1 Like

Update:

Changed truffle config entry for matic to:

     matic: {
       provider: () => new HDWalletProvider(secretKey, `https://speedy-nodes-nyc.moralis.io/a919256c3780769ae58d0149/polygon/mumbai`),
       network_id: 80001,
       gas: 6000000,           // Gas sent with each transaction (default: ~6700000)
       gasPrice: 3000000000,  // 3 gwei (in wei) (default: 100 gwei)
       confirmations: 2,
       timeoutBlocks: 200,
       skipDryRun: true
     },

Vslues based on previous remix deployment and the price suggestions in matic mubai gasstation. No truffle is trying to deploy but it would appear no miners are picking up the transaction. I am going to try playing around with the gasPrice value.

If anyone has insight into good gas values for matic mumbai - please let me know!

Thank you,

David

Was able to deploy using REMIX so the issue is in truffle. Adding whole truffle config:

const HDWalletProvider = require('@truffle/hdwallet-provider');
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();

module.exports = {
  plugins: ["truffle-contract-size"],

  networks: {
     development: {
      host: "127.0.0.1",     // Localhost (default: none)
      port: 7545,            // Standard Ethereum port (default: none)
      network_id: "*",       // Any network (default: none)
     },
     matic: {
       provider: () => new HDWalletProvider(mnemonic, "https://speedy-nodes-nyc.moralis.io/a919256c3780769ae58d0149/polygon/mumbai"),
       network_id: 80001,
       gas: 5500000,           // Gas sent with each transaction (default: ~6700000)
       gasPrice: 7000000000,  // 7 gwei (in wei) (default: 100 gwei)
       confirmations: 2,
       from: "0x5bE9bca32BfD527B40d82c6a2B2A9c7246027BFc",
       timeoutBlocks: 200,
       skipDryRun: false
     },
  },

  // Set default mocha options here, use special reporters etc.
  mocha: {
    // timeout: 100000
  },

  // Configure your compilers
  compilers: {
    solc: {
      version: "^0.8.0",    // Fetch exact version from solc-bin (default: truffle's version)
      // docker: true,        // Use "0.5.1" you've installed locally with docker (default: false)
      // settings: {          // See the solidity docs for advice about optimization and evmVersion
      //  optimizer: {
      //    enabled: false,
      //    runs: 200
      //  },
      //  evmVersion: "byzantium"
      // }
    },
  },
};
1 Like

I was able to successfully deploy all of my contacts to Mumbai using Remix. However I would still like to get Truffle working so that I can automated deployment. Any insight into why Truffle migrate does not work?

Thanks for pointing out working gas price settings for Mumbai, helped me out to deploy :partying_face:

3 Likes