I have an ERC20 contract which is deployed from another contract as following:
function createDao(string _tokenName) public payable returns (address tokenAddress) { tokenNumberIndex = safeAdd(tokenNumberIndex, 1); string memory _tokenSymbol = bytes32ToString(bytes32(tokenNumberIndex)); address _tokenAddress = new REP(_tokenSymbol, _tokenName); erc20SymbolAddresses[_tokenSymbol] = _tokenAddress; return _tokenAddress; } The ERC20 contract is as following:
contract REP is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor(string _tokenSymbol, string _name) public payable{ symbol = _tokenSymbol; name = _name; decimals = 18; _totalSupply = msg.value; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } }
My assumption is that since createDao function is payable, whatever is sent in createDao will be passed on to the ERC20 contract as msg.value. Though both the functions are payable, how do I pass on the value while initializing ERC20 token?