I'm trying to resolve a problem and google is not useful this time.
On my localhost truffle + testrpc I have a contract which returns a new instance of a new contract.
import 'contracts/MyBasicContract.sol';
contract Factory {
function createContract() returns (address created){
return new MyBasicContract();
}
}
What I'm trying to do is to generate a new contract with a new address on which I'll be able to call functions from the front-end. After deploying Factory I called function createContract which returns me address but still the same address again and again.
What am I doing wrong? Or how looks the best practise for generating new contracts with new address from frontend?
Thank you all for some hints.
Factory.deployed().then((e)=>{return e.createContract()})and then this give me a new address:
Factory.deployed().then((e)=>{return e.createContract.call()})and I'm comfused here why is it doing it and how I am supposed to do it at front end. My front-end look like this:
– Ondrej Sarnecký Oct 18 '17 at 19:13FactoryContract.methods.createContract().call().then((result) => { console.log('result ', result) //show address });.call()you are insisting that it should be a "dry-run" on not actually do anything, so that's incorrect if you want it to do something. IMO, this is too simplistic to support a front-end, although you could get somewhere with an event listener. For a more complete pattern with possibility of enumerating the deployed contracts, have a look at this: https://ethereum.stackexchange.com/questions/13415/is-there-a-simple-contract-factory-pattern – Rob Hitchens Oct 18 '17 at 19:26