1

I have a simple Parent contract that creates child contracts and stores their address.

contract Parent {
    address[] public registry;

    function createChild () public {
        address newChild = address(new Child());
        registry.push(newRecord);
    }
 }

 contract Record {
    string public uid;
 }

Using web3j generated wrappers, I try to call this creation method:

contract.createChild().send();

contract being the Parent instance. However I get this error:

{
  "timestamp": "2019-07-05",
  "status": 500,
  "error": "Internal Server Error",
  "message": "org/bouncycastle/jcajce/provider/digest/Keccak$DigestKeccak",
  "path": "/api/deployRecord"
}

Can anyone tell me why? Or can I achieve this some other way using web3j? It seems like a really simple thing to do :/

Thanks

1 Answer 1

0

Not an expert on web3j here, but you are trying to invoke something called contract.createRecord() when the function in the contract is called ...createChild().

The contract itself can't compile because you have a contract, Record, nested in a contract. It should look like:

contract Child {
  // stuff
}

contract Parent {
    address[] public registry;

    function createChild () public { // the function to invoke
        address newChild = address(new Child()); // the contract to create defined above
        registry.push(newRecord);
    }
}

Hope it helps.

2
  • Hi, apologies for the error in the code, my bad. I was trying to abstract the names. I have fixed the above code and can confirm the method name is correct, any idea what this may be?
    – Milo
    Commented Jul 8, 2019 at 7:03
  • I fiddled with the code a little more so Child isn't nested inside Parent. It looks good, in principle (this way), so I would suggest concentrating on the transaction. Does the sending account have funds to pay for gas? Is the account unlocked? Be sure you are calling an instance of Parent ... say, parent.createChild().send(). Commented Jul 8, 2019 at 14:50

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.