I'm new to ethereum and getting my hands on contracts (in solidity). I think I have a very simple question but I can't for the life of me find the answer.

Simply put: How to I invoke an internal function with enough gas, if it's complex?

Example: Imagine I'm setting up a savings system for my children. They can deposit ether to the contract, and after 10 years their savings will be paid back - but to encourage them, there will be a bonus pool of ether in the contract. The kid who have deposited the most ether will also get the biggest chunk of the bonus pool. They may send from different wallets, so the contract keeps track of their names as well.

Example contract code:

contract Savings
    struct Deposit
        string name;
        uint deposit;

    uint        cEnd = now + 10 years;
    address[]   dAddresses;

    mapping(address => Deposit[]) deposits;

    function depositEther(string _name)
            name: _name,
            deposit: msg.value

        if(now >= cEnd){
            distribute(); //CALL THIS WITH ENOUGH GAS

    //complex calculations
    function distribute() internal {

(I keep running into c.sendTransaction({from: to: gas: }) but I can not get that working.

If anyone could explain this to me in a simple way, I would be very happy.

1 Answer 1


Internal functions are called entirely internally to the EVM; it's simply a jump to another location in your bytecode. As a result, they use the same gas that the rest of the call to the contract used; you can't specify a smaller, fixed amount of gas only for the function call.

If you want to, you can make an external call to a function (that isn't marked internal visibility) with this.funcname.gas(1234)(args), but it imposes additional overhead, and can only ever be used to reduce the amount of gas - you can't specify more gas than the caller has available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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