SampleCrowdsale.sol 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. pragma solidity ^0.5.0;
  2. import "../crowdsale/validation/CappedCrowdsale.sol";
  3. import "../crowdsale/distribution/RefundableCrowdsale.sol";
  4. import "../crowdsale/emission/MintedCrowdsale.sol";
  5. import "../token/ERC20/ERC20Mintable.sol";
  6. import "../token/ERC20/ERC20Detailed.sol";
  7. /**
  8. * @title SampleCrowdsaleToken
  9. * @dev Very simple ERC20 Token that can be minted.
  10. * It is meant to be used in a crowdsale contract.
  11. */
  12. contract SampleCrowdsaleToken is ERC20Mintable, ERC20Detailed {
  13. constructor () public ERC20Detailed("Sample Crowdsale Token", "SCT", 18) {
  14. // solhint-disable-previous-line no-empty-blocks
  15. }
  16. }
  17. /**
  18. * @title SampleCrowdsale
  19. * @dev This is an example of a fully fledged crowdsale.
  20. * The way to add new features to a base crowdsale is by multiple inheritance.
  21. * In this example we are providing following extensions:
  22. * CappedCrowdsale - sets a max boundary for raised funds
  23. * RefundableCrowdsale - set a min goal to be reached and returns funds if it's not met
  24. * MintedCrowdsale - assumes the token can be minted by the crowdsale, which does so
  25. * when receiving purchases.
  26. *
  27. * After adding multiple features it's good practice to run integration tests
  28. * to ensure that subcontracts works together as intended.
  29. */
  30. contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale {
  31. constructor (
  32. uint256 openingTime,
  33. uint256 closingTime,
  34. uint256 rate,
  35. address payable wallet,
  36. uint256 cap,
  37. ERC20Mintable token,
  38. uint256 goal
  39. )
  40. public
  41. Crowdsale(rate, wallet, token)
  42. CappedCrowdsale(cap)
  43. TimedCrowdsale(openingTime, closingTime)
  44. RefundableCrowdsale(goal)
  45. {
  46. //As goal needs to be met for a successful crowdsale
  47. //the value needs to less or equal than a cap which is limit for accepted funds
  48. require(goal <= cap, "SampleCrowdSale: goal is greater than cap");
  49. }
  50. }