ERC721Mintable.sol 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. pragma solidity ^0.5.0;
  2. import "./ERC721.sol";
  3. import "../../access/roles/MinterRole.sol";
  4. /**
  5. * @title ERC721Mintable
  6. * @dev ERC721 minting logic.
  7. */
  8. contract ERC721Mintable is ERC721, MinterRole {
  9. /**
  10. * @dev Function to mint tokens.
  11. * @param to The address that will receive the minted token.
  12. * @param tokenId The token id to mint.
  13. * @return A boolean that indicates if the operation was successful.
  14. */
  15. function mint(address to, uint256 tokenId) public onlyMinter returns (bool) {
  16. _mint(to, tokenId);
  17. return true;
  18. }
  19. /**
  20. * @dev Function to safely mint tokens.
  21. * @param to The address that will receive the minted token.
  22. * @param tokenId The token id to mint.
  23. * @return A boolean that indicates if the operation was successful.
  24. */
  25. function safeMint(address to, uint256 tokenId) public onlyMinter returns (bool) {
  26. _safeMint(to, tokenId);
  27. return true;
  28. }
  29. /**
  30. * @dev Function to safely mint tokens.
  31. * @param to The address that will receive the minted token.
  32. * @param tokenId The token id to mint.
  33. * @param _data bytes data to send along with a safe transfer check.
  34. * @return A boolean that indicates if the operation was successful.
  35. */
  36. function safeMint(address to, uint256 tokenId, bytes memory _data) public onlyMinter returns (bool) {
  37. _safeMint(to, tokenId, _data);
  38. return true;
  39. }
  40. }