I've been trying to implement a DApp to the mainnet of ethereum and I keep running into this problem :
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
Starting migrations...
======================
> Network name: 'mainnet'
> Network id: 1
> Block gas limit: 30000000 (0x1c9c380)
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
Error: *** Deployment Failed ***
"Migrations" ran out of gas (using a value you set in your network config or deployment parameters.)
* Block limit: 30000000 (0x1c9c380)
* Gas sent: 139190886 (0x84be266)
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:364:1
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Migration._deploy (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:68:1)
at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:55:1)
at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:171:1)
at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
at Object.runFrom (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
at Object.runAll (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:114:1)
at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:79:1)
at runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:269:1)
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:231:1
Truffle v5.1.39 (core: 5.1.39)
Node v16.13.2
We have loaded over a $1000 eth in the deploying contract. Is there any way I could calculate the gas needed because it's becoming quite expensive?
Any help would be appreciated.
Thanks and regards
These are annoying bugs that often don't have a clear answer.
Few Things you can check:
--dry-run flag in truffle deploy, which gives more detailed errors.