- Inherit the winnable DAL contract created in the previous recipe. Since the investments are usually handled using an ERC20 token, import the StandardToken contract from the openzeppelin library:
pragma solidity^0.4.23;import "./WinnableDAL.sol";import "./StandardToken.sol";contract InvestableDAL is WinnableDAL, StandardToken { //...}
- Create an invest function, which accepts investments from the user and allocates tokens accordingly:
function invest() public { //...}
- For simplicity, assume that each investor gets one token per Ether invested. Use the standard token functions to mint and allocate tokens:
address investor = msg.sender;uint tokens = msg.value;mint(investor, tokens);
- Create a state variable to store the dividend ...