Search code examples
ethereumsoliditygethkaleido

Ethereum Transaction Error while calling a contract function from another contract


Following smart contract works fine in Remix and Ganache. However doesn't work on private ethereum blockchains like Kaleido or Azure. What am I missing. When I call setA it consumes all gas and then fails.

pragma solidity ^0.4.24;

contract TestA {
    uint public someValue;

    function setValue(uint a) public returns (bool){
        someValue = a;
        return true;
    }
}

contract TestB {
    address public recentA;

    function createA() public returns (address) {
        recentA = new TestA();
        return recentA;
    }

    function setA() public returns (bool) {
        TestA(recentA).setValue(6);
        return true;
    }
}

Solution

  • You are hitting the limit of gas allowed to be spent per block. Information about gas limit is included into every block, so you can check what's this value is right now in your blockchain. Currently on Ethereum MainNet, GasLimit (per block) is about 8 millions (see here https://etherscan.io/blocks)

    To fix this, you can start your blockchain with modified genesis file. Try to increase value of gasLimit parameter in your genesis file, which specifies the maximum amount of gas processed per block. Try "gasLimit": "8000000".