Deploying to mainnet using polygon network

Hello all I have been working on ERC20 token and everything was ok following the academy course.
However, I got stuck when trying to deploy to the mainnet.

here is my truffle config

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

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",     // Localhost (default: none)
      port: 8545,            // Standard Ethereum port (default: none)
      network_id: "*",       // Any network (default: none)
    },
    matic: {
      provider: () => new HDWalletProvider(mnemonic, `https://speedy-nodes-nyc.moralis.io/02e18687589adb82ff079d51/polygon/mainnet`),
      network_id: 137, //80001 for mumbai , 137 for mainnet
      confirmations: 2,
      timeoutBlocks: 200,
      skipDryRun: true
    },
  },

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

  // Configure your compilers
  compilers: {
    solc: {
      version : "0.8.13"
    }
  }
}

Steps to reproduce my error : -
truffle compile
truffle migrate --network matic

error message : -
null

C:\Users\HussainAlkhateeb\Desktop\Phantom Troupe Copy\node_modules\web3-provider-engine\index.js:160
cb(null, null)
^
Error: Could not find block
at C:\Users\HussainAlkhateeb\Desktop\Phantom Troupe Copy\node_modules\web3-provider-engine\index.js:59:28

sometimes i get another message (following the exact steps) :-
the “ETIMEDOUT” error

THANKS FOR YOUR HELP !

1 Like

yeah truffl ei svery bugg like this theres not an easy plain anwser to the cause your just going to have to play around with the params in truffle config.

however an easier way is to take your code into remix and deploy to mainnet using injected web3 as the provider

1 Like

thank you mcgrane you really respond really fast.

So , is there any url video you would recommend for remix?
My only concern is the mnemonic as you may know in truffle it has to go to “.secret” not to mention that
I need to adjust a couple things for openzeepline right?

1 Like

that doesnnt matter u just need remix to deploy it. once its deployed u can interact with the contrct in your javascript client. you only need your secret when deploying manually from truffle because its a script your writing. however deploying with remix is done through metamask and you sign the message there so metamask handles everything for u

1 Like

hello mcgrane , so I have taken your advice into consideration (tried to adjust the params in truffle didnt work out well)
and so , I tried to deploy using remix I believe everything is correct however, my transaction is pending on the network (I believe I need to pay more for gas?) because it is pending for a long time.

Do you have any idea how to fix that issue , how much should I pay ? + how can I adjust the gas fees to that number?

THANKS !

1 Like

im not sure it should work maybe you could try using an extra gas price