SampleCrowdsale.sol 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. pragma solidity ^0.4.11;
  2. import "../crowdsale/CappedCrowdsale.sol";
  3. import "../crowdsale/RefundableCrowdsale.sol";
  4. import "../token/MintableToken.sol";
  5. /**
  6. * @title SampleCrowdsaleToken
  7. * @dev Very simple ERC20 Token that can be minted.
  8. * It is meant to be used in a crowdsale contract.
  9. */
  10. contract SampleCrowdsaleToken is MintableToken {
  11. string public constant name = "Sample Crowdsale Token";
  12. string public constant symbol = "SCT";
  13. uint8 public constant decimals = 18;
  14. }
  15. /**
  16. * @title SampleCrowdsale
  17. * @dev This is an example of a fully fledged crowdsale.
  18. * The way to add new features to a base crowdsale is by multiple inheritance.
  19. * In this example we are providing following extensions:
  20. * CappedCrowdsale - sets a max boundary for raised funds
  21. * RefundableCrowdsale - set a min goal to be reached and returns funds if it's not met
  22. *
  23. * After adding multiple features it's good practice to run integration tests
  24. * to ensure that subcontracts works together as intended.
  25. */
  26. contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale {
  27. function SampleCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _goal, uint256 _cap, address _wallet)
  28. CappedCrowdsale(_cap)
  29. FinalizableCrowdsale()
  30. RefundableCrowdsale(_goal)
  31. Crowdsale(_startTime, _endTime, _rate, _wallet)
  32. {
  33. //As goal needs to be met for a successful crowdsale
  34. //the value needs to less or equal than a cap which is limit for accepted funds
  35. require(_goal <= _cap);
  36. }
  37. function createTokenContract() internal returns (MintableToken) {
  38. return new SampleCrowdsaleToken();
  39. }
  40. }