I am using a factory pattern to deploy its children contracts here.
The child contract has a constructor as followed:
constructor (
string memory _potName,
uint _duration,
uint _minStake,
PotType _potType
)
public payable {
require(msg.value >= _minStake);
...
}
The factory contract create the child contract as:
function createLotteryPot(
string memory potName, uint duration, uint minStake,
LotteryPot.PotType potType
) public payable returns(LotteryPot) {
LotteryPot newContract = new LotteryPot({ _potName: potName,
_duration: duration, _minStake: minStake, _potType: potType });
...
}
My questions are:
In the factory contract, how can I pass the
msg.value
to the children contract? This is a requirement that during child contract creation, the owner also need to commit some ethereum.How can I pass the
msg.sender
to the children contract to specify it is the owner instead of the contract? I understand I can pass in an additional parametermsg.sender
. Just wonder is there a cleaner way to do it?
Thanks a lot for input.