SampleCrowdsale.sol 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. }
  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. * MintedCrowdsale - assumes the token can be minted by the crowdsale, which does so
  23. * when receiving purchases.
  24. *
  25. * After adding multiple features it's good practice to run integration tests
  26. * to ensure that subcontracts works together as intended.
  27. */
  28. // XXX There doesn't seem to be a way to split this line that keeps solium
  29. // happy. See:
  30. // https://github.com/duaraghav8/Solium/issues/205
  31. // --elopio - 2018-05-10
  32. // solium-disable-next-line max-len
  33. contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale {
  34. constructor (
  35. uint256 openingTime,
  36. uint256 closingTime,
  37. uint256 rate,
  38. address payable wallet,
  39. uint256 cap,
  40. ERC20Mintable token,
  41. uint256 goal
  42. )
  43. public
  44. Crowdsale(rate, wallet, token)
  45. CappedCrowdsale(cap)
  46. TimedCrowdsale(openingTime, closingTime)
  47. RefundableCrowdsale(goal)
  48. {
  49. //As goal needs to be met for a successful crowdsale
  50. //the value needs to less or equal than a cap which is limit for accepted funds
  51. require(goal <= cap);
  52. }
  53. }