3

geth comand

geth --rpc --rpcapi db,eth,net,web3,personal

Truffle.js

module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*" // Match any network id
},
live: {
network_id: 1,
host: "127.0.0.1",
port: 8545, // Different than the default below
from: "address",
gas: 4612388
}
}
};

Truffle MIgration:

truffle migrate --network live
Using network 'live'.

Running migration: 1_initial_migration.js
Deploying Migrations...
... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: exceeds block gas limit
at Object.InvalidResponse (/usr/lib/node_modules/truffle/build/cli.bundled.js:43303:16)
at /usr/lib/node_modules/truffle/build/cli.bundled.js:331156:36
at /usr/lib/node_modules/truffle/build/cli.bundled.js:175492:11
at /usr/lib/node_modules/truffle/build/cli.bundled.js:314196:9
at XMLHttpRequest.request.onreadystatechange (/usr/lib/node_modules/truffle/build/cli.bundled.js:315621:13)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/lib/node_modules/truffle/build/cli.bundled.js:70159:18)
at XMLHttpRequest._setReadyState (/usr/lib/node_modules/truffle/build/cli.bundled.js:70449:12)
at XMLHttpRequest._onHttpResponseEnd (/usr/lib/node_modules/truffle/build/cli.bundled.js:70604:12)
at IncomingMessage. (/usr/lib/node_modules/truffle/build/cli.bundled.js:70564:24)
at emitNone (events.js:91:20)

OS: Ubuntu 16.04 Node: 6.2 npm: 3.10 Contract is being deployed easily on testrpc and rinkeby only problem is publishing it on live network. git hub error link. https://github.com/trufflesuite/truffle/issues/773

4 Answers4

4

See Ankush answer: https://ethereum.stackexchange.com/a/6310/44800

with command eth.getBlock("latest") you get your gas limit maximum. I have similar problem, and with this info it works when I set my gas (limit) for this maximum. At my case it was 5000000 (higher than truffle default 4712388)

Another way is to reset node gas limit: see: How to increase gas limit in block using geth?

dchang
  • 159
  • 4
2

I am using Hardhat with ethers.js

For the error message: 'ProviderError: exceeds block gas limit'

Solution: The gas or gasLimit was too high.

For Rinkeby or Polygon/Matic, set both of the networks' gas to 25e6 and 15e6 respectively in Hardhat config file:

rinkeby: {
  url: ...,
  accounts: [...],
  gasPrice: 20e9,
  gas: 25e6,
},
Russo
  • 1,784
  • 1
  • 21
  • 30
1

in your migrations you have to specify the gas amount

1

You're probably overlooking the need to unlock and fund the account you're deploying from.

Have a look over here: truffle deploy: Network state unknown when geth is synced

Hope it helps.

Rob Hitchens
  • 55,151
  • 11
  • 89
  • 145