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
},
rinkeby: {
host: "localhost", // Connect to geth on the specified
port: 8545,
from: "0x1C11f6b1A2d1c0b00ad4145eb067184736EB973f", // default address to use for any transaction Truffle makes during migrations
network_id: 4,
gas: 4612388 // Gas limit used for deploys
},
live: {
network_id: 1,
host: "127.0.0.1",
port: 8545, // Different than the default below
from: "0x1C11f6b1A2d1c0b00ad4145eb067184736EB973f",
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.
at emitNone (events.js:91:20)
OS: Ubuntu 16.04
Node: 6.2
npm: 3.10
I have even tried this contract
pragma solidity ^0.4.2;
contract test {
string public name;
function test() public {
name = 'test';
}
}
but still same error.,
Even with gas = 0
live: {
network_id: "*",
host: "127.0.0.1",
port: 8546, // Different than the default below
from: "address",
gas: 0
}
on side note i only have 0.10000 ether in my account, i hope that is enough to deploy smart contract though.
@inzig Which Truffle version are you using? Which Ethereum client are you running?
@cgewecke
Truffle v4.0.1 (core: 4.0.1)
Solidity v0.4.18 (solc-js)
@inzig, Thanks. The second contract you reference (like the one below) has invalid gas values:
live: {
network_id: "*",
host: "127.0.0.1",
port: 8546, // Different than the default below
from: "address",
gas: 0 // <--- Use more, perhaps 6700000. Current main net block limit is ~8003929
}
Does changing that allow you to deploy the example contract? It's a little difficult to say what the issue might be with the 'real' contract you're working with from your first comment.
Closing this as duplicate because problems with gas during deployments are currently being tracked and discussed by the community in issue #271, but please feel free to re-open this if you discover a problem that isn't addressed over there.
I have tried everything discussed there, i have tried simplest the contracts even but still facing the same error.
@inzig I'll happily look into this further if you can provide a way of reproducing the error you're seeing. Please link to a simple example repository which includes all the relevant files including truffle.js, migrations, contracts etc. Also include the version of your geth client. Thanks!
@inzig did you resolve this? I'm facing the same issue.
@cgewecke I can provide the metadata if this still is not resolved.
@boorac Yes if you have a way to reproduce please do! Happy to take a look.
Actually, I think I managed to figure this out! There was a bug in geth v1.8.1 and truffle 4.0.6 - the issue was fixed in truffle 4.0.7 yesterday and I'm now able to deploy to privatenet.
$truffle migrate
Using network 'development'.
Running migration: 1_initial_migration.js
Deploying Migrations...
... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: insufficient funds for gas * price + value
at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1)
at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:86:1
at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-migrate/index.js:225:1
at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:134:1
at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
at IncomingMessage.
at IncomingMessage.emit (events.js:185:15)
at endReadableNT (_stream_readable.js:1101:12)
at process._tickCallback (internal/process/next_tick.js:114:19)
truffle.js
require('babel-register')
module.exports = {
networks: {
development: {
host: 'localhost',
port: 8545,
network_id: '*',
from: "0x3f2d15c8c040a8faee4477a748a2950379f083c0",
gas: 6721975
}
}
}
@JebasinghMathan it works for me.
I add "from" in truffle.js
I am still having the same error, If anyone has solved this thing please share it
Using network 'production'.
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 (C:UsersAshfaqAppDataRoamingnpmnode_modulestrufflebuildwebpack:~web3libweb3errors.js:38:1)
at C:UsersAshfaqAppDataRoamingnpmnode_modulestrufflebuildwebpack:~web3libweb3requestmanager.js:86:1
at C:UsersAshfaqAppDataRoamingnpmnode_modulestrufflebuildwebpack:~truffle-core~truffle-migrateindex.js:225:1
at C:UsersAshfaqAppDataRoamingnpmnode_modulestrufflebuildwebpack:~truffle-providerwrapper.js:134:1
at XMLHttpRequest.request.onreadystatechange (C:UsersAshfaqAppDataRoamingnpmnode_modulestrufflebuildwebpack:~web3libweb3httpprovider.js:128:1)
at XMLHttpRequestEventTarget.dispatchEvent (C:UsersAshfaqAppDataRoamingnpmnode_modulestrufflebuildwebpack:~xhr2libxhr2.js:64:1)
at XMLHttpRequest._setReadyState (C:UsersAshfaqAppDataRoamingnpmnode_modulestrufflebuildwebpack:~xhr2libxhr2.js:354:1)
at XMLHttpRequest._onHttpResponseEnd (C:UsersAshfaqAppDataRoamingnpmnode_modulestrufflebuildwebpack:~xhr2libxhr2.js:509:1)
at IncomingMessage.
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1056:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
This is still an issue using Truffle 4.1.7 and geth 1.8.6.
It just started happening today. All my contracts, and I mean all, are now not deploying or testing. They work with Ganache, but Ganache is useless except for testing.
@ahester57 We now run truffle against geth:latest in continuous integration and our end-to-end migrations tests are passing.
Ganache has a default gas limit ~6700000. Other networks vary - for example Ropsten is ~4700000. If you can provide some context for what you're trying to do, what your client and truffle config are like etc, there might be a straightforward way to resolve it.
@cgewecke I solved the issue by deleting all of the chain data and re-initialized the whole (private) chain. Truffle config just has development with normal everything, gas set slightly below what geth told me was the gas limit. It was working fine until I started an npm server running a Dapp, then it just stopped working even after a system reboot.
Something bad happened because of one of these actions. I could not tell you why at all. I wouldn't worry about it too much since it was such a specific issue.
I am still a rookie to the whole blockchain thing, the contract works fine (without gas limit ) on testrpc. But, when I am trying to run the same contract(without gas limit) on the network chain (I am running the blockchain network on the Microsoft Azure portal), I get the error of exceeds the gas limit.
when I run the contract with the gas limit, then when I migrate the whole project it is
stuck on deploying the contract.
@ashfaqnisar Does it deploy Migrations at all? Or just stuck after Migrations?
Nevermind, I see your trace above. It may have something to do with Azure. The issue I ran into was solved by reinstalling my blockchain client.
@ahester57 So, if do the deployment in ganache then I won't have a problem??
@ahester57 I run test on Ganache without this error Error: exceeds block gas limit
My truffle and Solidity version
Truffle v4.1.8 (core: 4.1.8)
Solidity v0.4.23 (solc-js)
@hadv I am able to run it on ganache but when I try to run it on the azure server, it is just stuck on deploying the migrations. Do have any solution for this
I have the same issue while deploying to Azure by following this tutorial . Local deployment works fine.
Error:
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: exceeds block gas limit
```
Truffle v4.1.11
Solidity v0.4.23
Code:
```javascript
pragma solidity ^0.4.23;
contract ScoreStore {
mapping(string => int) PersonScores;
function AddPersonScore(string name, int startingScore) public {
PersonScores[name] = startingScore;
}
function GetScore(string name) public returns (int) {
return PersonScores[name];
}
}
Experience the same issue with:
Truffle v4.1.8 (core: 4.1.9)
Solidity v0.4.24 (solc-js)
I have to explicilty declare gas in my truffle.js
module.exports = {
networks: {
development: {
host: "xxx",
port: xx,
network_id: "xx",
gas: 4712388
}
}
}
then it works
I'm running this on:
Truffle v4.1.11 (core: 4.1.11)
Solidity v0.4.24 (solc-js)
Deploying on Ganache.
What I had to do to make it work was set a gas limit of 670000
networks: {
development: {
host: '127.0.0.1',
port: 7545,
network_id: '*', // Match any network id
gas: 6700000,
}
And in Ganache set the limit ( press the settings icon on the top right, then go to chain, then set the limit t0 6700000) and it should work! I think the problem was with the limit set in Ganache.
What @ayanez17 mentioned worked for me.
I experienced the same issue with:
Truffle v4.1.11 (core: 4.1.11)
Solidity v0.4.24 (solc-js)
Deploy to Rinkeby Test Network
Truffle v4.1.14 (core: 4.1.14)
Solidity v0.4.24 (solc-js)
getting the same error too on ropsten
For those using ganache-cli
Ganache-cli has a default gasLimit of 0x6691b7,
so your gas value in truffle.js must not exceed it.
If you need a higher gasLimit, you need to set a higher gasLimit when starting ganache-cli
ganache-cli -l 8000000
https://github.com/trufflesuite/ganache-cli#command-line
I resolved the error that exceeds block gas limit by reinitializing my privatechain.Just as the error says the gas cost exceeds, i set the gaslimit in genesis.json to be 0xffffffff(used to be 0x2fefd8),and reinitialize.
Hope that helps
Most helpful comment
For those using
ganache-cliGanache-cli has a default
gasLimitof0x6691b7,so your
gasvalue in truffle.js must not exceed it.If you need a higher gasLimit, you need to set a higher gasLimit when starting ganache-cli
ganache-cli -l 8000000https://github.com/trufflesuite/ganache-cli#command-line