1

I'm creating a Main contract which will be used to create dynamic contracts with msg.sender as Owner. Anyone can send ETH externally to the dynamic contract and anyone can withdraw ETH from the dynamic contract but it will only goto Owner.

main.sol

contract Main{
   // this contract will just create contracts
   mapping(address => address[]) public dynamic_contracts;
   function createContract(){
      address newContract = new Dynamic(msg.sender);
      dynamic_contracts[msg.sender].push(newContract);
   }
}

dynamic.sol

Contract Dynamic{
 // this contract will hold funds and transfer em
    address Owner;
    function Dynamic (address owner) {
        Owner = owner;
    } 
    function transferFunds(){
      //transfer it to Owner
      Owner.transfer(this.balance())
    }
}

The problem is Dynamic contract is created dynamically therefore i only have its address stored in mapping dynamic_contracts of Main. I don have its abi so how do i call transferFunds function ?

1 Answer 1

1
Dynamic = Dynamic(msg.sender);

Dynamic.transferFunds();

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.