i studying remix and ethereum, and create my local blockchain.

and create contract with remix.the contract just print simple word.

pragma solidity ^0.4.8;

contract HelloWorld{
    string public greeting;
    function HelloWorld(string _greeting){
        greeting = _greeting;

    function setGreeting(string _greeting){
        greeting = _greeting;

    function say() constant returns(string){
        return greeting;

and i set gas limit 300,000, set _greeting to Hola!

setting img

contract working well, and there is no error on this contract.

and i see the block that this contract is contained.

  difficulty: 182546,
  extraData: "0xda83010815846765746888676f312e31312e348777696e646f7773",
  gasLimit: 7770496,
  gasUsed: 370469,
  hash: "0x16b515fcb7fc23220de291e9432fc039897cf46ee17577cb4eb251a989b10511",
  logsBloom: "0x000000000....0000",
  miner: "0x6b169bf30ca51fcb3034a8d161698b0f4e7bd168",
  mixHash: "0xf6f531bbe531cf83cbb7bcd278ddcec9e2220d69605f6cebe4ac33c992862eaf",
  nonce: "0x3dbb8a68d74d72a0",
  number: 1341,
  parentHash: "0x22a5d086704d663d56dca62dfe08f06e5e71bd26fb0275b918770d01c87381e8",
  receiptsRoot: "0xa655c0137e500bcdafa23d9ab58f0067945700cfef1e158dd3d9b9d9e4cab059",
  sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  size: 2039,
  stateRoot: "0xe81510bb99242c3fe03a45f55a8d7822b5cb95ed5cfda58becfb676a2501928c",
  timestamp: 1551674879,
  totalDifficulty: 221589793,
  transactions: ["0xf662dbbc8012dc97588d911efc63f9163b16f9aa373bd3627df395ba2c683065"],
  transactionsRoot: "0xeb61642c2d5880b38d97ba98213e50db4921b7aec9e28852f89c9ac88f69bc84",
  uncles: []

gasUsed: 370469,

it say the gas used over 300,000.

As a result, there is no error. but it doesn't make sense. l learn when gas limit is over, the contract will not execute.

  • You are looking at the block details. You should also examine the transaction 0xf662dbbc8012dc97588d911efc63f9163b16f9aa373bd3627df395ba2c683065, perhaps it is a transaction generated trough means other than Remix where the 300k limit will not apply. – Ismael Apr 3 '19 at 20:08

I'm not sure I understand the question.

It sounds like you deployed the contract when Remix had a default block gasLimit to 3,000,000 and the transaction cost 370,000, so it worked.

Then you lowered the gasLimit to 300,000 and tried a few transactions. They required less than 300,000 gas, so they also worked.

The gasLimit is an upper bound on transaction cost. It applies to all transactions including deployment. More precisely, it the maximum gas allowed for all transactions in a block and it's decided by the miners (i.e. block size), so it's a property of the network. Since a transactions with higher gasCost than an entire block allows can't be executed, such transactions are an automatic fail. Remix (JavaScript VM) is merely emulating this by letting you choose the gasLimit number.

The default is 3,000,000 gas. On mainnet, the actual gasLimit has been around 8,000,000 for a while and we (developers) don't control it.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.