MintedCrowdsale.sol 822 B

123456789101112131415161718192021222324
  1. pragma solidity ^0.5.0;
  2. import "../Crowdsale.sol";
  3. import "../../token/ERC20/ERC20Mintable.sol";
  4. /**
  5. * @title MintedCrowdsale
  6. * @dev Extension of Crowdsale contract whose tokens are minted in each purchase.
  7. * Token ownership should be transferred to MintedCrowdsale for minting.
  8. */
  9. contract MintedCrowdsale is Crowdsale {
  10. /**
  11. * @dev Overrides delivery by minting tokens upon purchase.
  12. * @param beneficiary Token purchaser
  13. * @param tokenAmount Number of tokens to be minted
  14. */
  15. function _deliverTokens(address beneficiary, uint256 tokenAmount) internal {
  16. // Potentially dangerous assumption about the type of the token.
  17. require(
  18. ERC20Mintable(address(token())).mint(beneficiary, tokenAmount),
  19. "MintedCrowdsale: minting failed"
  20. );
  21. }
  22. }