I want to use a factory so that people can create a standardized contract. People should be able to transfer money directly by this creation which led me to the problem of the msg.sender during the exceution. I read that tx.origin has some security flaws but I wonder if this is also true just for the creation of contracts by a factory. Following example contract:
pragma solidity ^0.4.0;
contract Factory {
address[] public contracts;
function createContract ()
payable
public
{
Con newCon = (new Con).value(msg.value)();
contracts.push(newCon);
}
}
contract Con {
address owner;
uint256 valueOwner
;
function Con()
payable
public
{
owner = tx.origin;
valueOwner = msg.value;
}
function withdraw ()
public
{
if(msg.sender == owner)
msg.sender.transfer(valueOwner);
}
}
I do not see why tx.origin should do any harm here or am I missing some point?