1

I have the following Solidity code:

pragma solidity ^0.4.17;

contract Parent {
   function createChild() public {
        new Child();
    }
}

contract Child {

}

Which I'm calling with web3 like this:

const item = await managerABI.methods.createChild().send({
   from: accounts[0],
   gas: '5000000',
})

Although the function is very simple and the gas limit is very high, I'm getting the error Transaction ran out of gas. Additionally, the full error message shows "gasUsed": 21577, which appears to mean that the actual gas used in the operation was well below the limit.

Any help is appreciated.

2
  • Have you tried assigning the value of new Child() to an address variable? Jul 9 '18 at 12:33
  • Yes, still getting the error. Jul 10 '18 at 3:23
1

Turned out to be a very simple issue. I was tweaking my solidity code and updating the ABI, but not updating the address of the Parent contract after redeploying.

I actually had other getter methods that were working because I was not making changes to those, which added to the confusion.

Make sure to update your ABI and contract addresses after deploying!

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.