Send Ether From Specific Address On Constructor

Viewed 100

I am implementing a factory pattern contract and on my constructor I want to trigger a function which deposits into the contract

--Factory--

function newChild() {
     Child child = new Child(potentialPayoutAmount);
     children[_childId] = address(child);
}

function getChild()view public returns (address)  {
   return children[_campaignId];
}

--Child Contract--

address payable public spender;

constructor(uint256 _potentialPayoutAmount) {
  autoDeposit(_potentialPayoutAmount)
}

function autoDeposit(uint256 _potentialPayoutAmount) {
  depositedFor[receiver] = depositedFor[receiver] + _potentialPayoutamount;
}

So my problem is that I want the spender address in the child contract to be the account that is spending the money, even though the autoDeposit function is obviously being triggered from the factory contract.

Any suggestions would help. Happy to elaborate if I was unclear.

Thanks!

0 Answers
Related