0

I'm running into a issue here "Contract C" is not being created. 3 Contracts: A, B, and C. I would like to call Contract A to create Contract B, that creates Contract C from B constructor. Example:

import ContractB.sol

contract ContractA {

    function createContractB(string _string1, string _string2) {
        address newContractB = new ContractB(_string1, _string2);
    }
}

//-----------------//

import ContractC.sol

contract ContractB {

    constructor(string _string1, string _string2) {
        createContractC(_string1);
        createContractC(_string2);
    }

    function createContractC(string _string) {
        address newContractC = new ContractC(_string);
    }
}

//-----------------//

contract ContractC {
    string thing;

    constructor(string _string) {
        thing = _string;
    }

}

Web3 call:

this.state.contractAInstance.createContractB(
        "string1", 
        "string2", 
        {account, gasPrice}
)

Edit: I am using metamask in my test environment, and without the createContractC function everything works fine, so it seems there is an issue between ContractB and ContractC creation, just not sure of the solution.

Edit2: Upon initiating createContractB transaction, metamask doesn't give gas estimation and gives errors:

inpage.js:1 MetaMask - RPC Error: Error: Error: [ethjs-rpc] rpc error with payload {"id":5645771625703,"jsonrpc":"2.0","params":["0xf9012c208504a817c800830186a0944e71920b7330515faf5ea0c690f1ad06a85fb60c80b8c457447733000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003757361000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000056368696e61000000000000000000000000000000000000000000000000000000822d46a00f9fac3cfe5ff22ead819d6b6ab2df01c9f25101c3e23141b5b8423facb3cf7ca07c13275ae3a0361084d375db684016262c8b52fcb858935adfe0cd4de55dde8a"],"method":"eth_sendRawTransaction"} Error: VM Exception while processing transaction: revert {code: -32603, message: "Error: Error: [ethjs-rpc] rpc error with payload {…VM Exception while processing transaction: revert"}
(anonymous) @ inpage.js:1
(anonymous) @ inpage.js:1
(anonymous) @ inpage.js:1
u @ inpage.js:1
(anonymous) @ inpage.js:1
He @ inpage.js:1
(anonymous) @ inpage.js:1
value @ inpage.js:1
(anonymous) @ inpage.js:1
n @ inpage.js:1
i @ inpage.js:1
(anonymous) @ inpage.js:1
(anonymous) @ inpage.js:1
n @ inpage.js:1
i @ inpage.js:1
(anonymous) @ inpage.js:1
(anonymous) @ inpage.js:1
(anonymous) @ inpage.js:1
(anonymous) @ inpage.js:1
u @ inpage.js:1
s @ inpage.js:1
(anonymous) @ inpage.js:1
(anonymous) @ inpage.js:1
(anonymous) @ inpage.js:1
setTimeout (async)
write @ inpage.js:1
b @ inpage.js:1
(anonymous) @ inpage.js:1
g.write @ inpage.js:1
y @ inpage.js:1
(anonymous) @ inpage.js:1
a.emit @ inpage.js:1
w @ inpage.js:1
_ @ inpage.js:1
v.push @ inpage.js:1
_write @ inpage.js:1
b @ inpage.js:1
(anonymous) @ inpage.js:1
g.write @ inpage.js:1
y @ inpage.js:1
(anonymous) @ inpage.js:1
a.emit @ inpage.js:1
w @ inpage.js:1
_ @ inpage.js:1
v.push @ inpage.js:1
i._onMessage @ inpage.js:1
postMessage (async)
c._write @ contentscript.js:1
L @ contentscript.js:1
(anonymous) @ contentscript.js:1
h.write @ contentscript.js:1
I @ contentscript.js:1
(anonymous) @ contentscript.js:1
m.emit @ contentscript.js:1
V @ contentscript.js:1
a @ contentscript.js:1
o.push @ contentscript.js:1
c._onMessage @ contentscript.js:1
EventImpl.dispatchToListener @ VM89 extensions::event_bindings:403
publicClassPrototype.(anonymous function) @ VM95 extensions::utils:138
EventImpl.dispatch_ @ VM89 extensions::event_bindings:387
EventImpl.dispatch @ VM89 extensions::event_bindings:409
publicClassPrototype.(anonymous function) @ VM95 extensions::utils:138
dispatchOnMessage @ VM96 extensions::messaging:392
errors.js:35 Uncaught (in promise) Error: Error: Error: [ethjs-rpc] rpc error with payload {"id":5645771625703,"jsonrpc":"2.0","params":["0xf9012c208504a817c800830186a0944e71920b7330515faf5ea0c690f1ad06a85fb60c80b8c457447733000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003757361000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000056368696e61000000000000000000000000000000000000000000000000000000822d46a00f9fac3cfe5ff22ead819d6b6ab2df01c9f25101c3e23141b5b8423facb3cf7ca07c13275ae3a0361084d375db684016262c8b52fcb858935adfe0cd4de55dde8a"],"method":"eth_sendRawTransaction"} Error: VM Exception while processing transaction: revert
    at Object.InvalidResponse (errors.js:35)
    at requestmanager.js:86
    at inpage.js:1
    at inpage.js:1
    at i (inpage.js:1)
    at inpage.js:1
    at inpage.js:1
    at u (inpage.js:1)
    at s (inpage.js:1)
    at inpage.js:1

Now I would like to create ContractA and then call it to create the ContractB, which then creates the Contract C's. Is this possible? I am using truffle framework is there perhaps a solution there? If more information needed please let me know.

  • "it seems there is an issue" Perhaps you could tell us what that issue is? :-) – user19510 Jul 28 '18 at 18:13
  • Contract C is not being created. – Jaren L Jul 29 '18 at 13:35
  • How are you determining that? – user19510 Jul 29 '18 at 14:01
  • Everything goes fine until Contract B calls createContractC. No createContractC it works. createContractC it does not. Is there an example of web3 creating a contract C in such a manner I think the problem is there I don't know how to fix it. – Jaren L Jul 29 '18 at 15:48
  • What do you mean by "it doesn't work?" Is there an error message? What does it say? – user19510 Jul 29 '18 at 15:50

Your Answer

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

Browse other questions tagged or ask your own question.