12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- pragma solidity ^0.4.24;
- import "./ERC721Full.sol";
- import "../../access/roles/MinterRole.sol";
- /**
- * @title ERC721Mintable
- * @dev ERC721 minting logic
- */
- contract ERC721Mintable is ERC721Full, MinterRole {
- event MintingFinished();
- bool private _mintingFinished = false;
- modifier onlyBeforeMintingFinished() {
- require(!_mintingFinished);
- _;
- }
- /**
- * @return true if the minting is finished.
- */
- function mintingFinished() public view returns(bool) {
- return _mintingFinished;
- }
- /**
- * @dev Function to mint tokens
- * @param to The address that will receive the minted tokens.
- * @param tokenId The token id to mint.
- * @return A boolean that indicates if the operation was successful.
- */
- function mint(
- address to,
- uint256 tokenId
- )
- public
- onlyMinter
- onlyBeforeMintingFinished
- returns (bool)
- {
- _mint(to, tokenId);
- return true;
- }
- function mintWithTokenURI(
- address to,
- uint256 tokenId,
- string tokenURI
- )
- public
- onlyMinter
- onlyBeforeMintingFinished
- returns (bool)
- {
- mint(to, tokenId);
- _setTokenURI(tokenId, tokenURI);
- return true;
- }
- /**
- * @dev Function to stop minting new tokens.
- * @return True if the operation was successful.
- */
- function finishMinting()
- public
- onlyMinter
- onlyBeforeMintingFinished
- returns (bool)
- {
- _mintingFinished = true;
- emit MintingFinished();
- return true;
- }
- }
|