- Create a crowdsale contract that can be used for the Initial Coin/Token Offering process. Import SafeMath for arithmetic operations:
pragma solidity ^0.4.23;import "./math/SafeMath.sol";contract CrowdSale { // ..}
- If you are distributing tokens to investors, then import the token contract and create a state variable to keep the address of the distributable token contract:
pragma solidity ^0.4.23;import "./math/SafeMath.sol";import "./ERC20.sol";contract CrowdSale { // The token sold through the ICO ERC20 public token;}
- Tokens sold for each purchase are calculated at a rate; create a state variable to store it in the contract. The rate parameter stores the number of tokens the buyer gets for a Wei:
uint256 public rate; ...