-
Notifications
You must be signed in to change notification settings - Fork 12
/
KIP17MetadataMintable.sol
43 lines (38 loc) · 1.45 KB
/
KIP17MetadataMintable.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
pragma solidity ^0.5.0;
import "./KIP17Metadata.sol";
import "./roles/MinterRole.sol";
import "./introspection/KIP13.sol";
/**
* @title KIP17MetadataMintable
* @dev KIP17 minting logic with metadata.
*/
contract KIP17MetadataMintable is KIP13, KIP17, KIP17Metadata, MinterRole {
/*
* bytes4(keccak256('mintWithTokenURI(address,uint256,string)')) == 0x50bb4e7f
* bytes4(keccak256('isMinter(address)')) == 0xaa271e1a
* bytes4(keccak256('addMinter(address)')) == 0x983b2d56
* bytes4(keccak256('renounceMinter()')) == 0x98650275
*
* => 0x50bb4e7f ^ 0xaa271e1a ^ 0x983b2d56 ^ 0x98650275 == 0xfac27f46
*/
bytes4 private constant _INTERFACE_ID_KIP17_METADATA_MINTABLE = 0xfac27f46;
/**
* @dev Constructor function.
*/
constructor () public {
// register the supported interface to conform to KIP17Mintable via KIP13
_registerInterface(_INTERFACE_ID_KIP17_METADATA_MINTABLE);
}
/**
* @dev Function to mint tokens.
* @param to The address that will receive the minted tokens.
* @param tokenId The token id to mint.
* @param tokenURI The token URI of the minted token.
* @return A boolean that indicates if the operation was successful.
*/
function mintWithTokenURI(address to, uint256 tokenId, string memory tokenURI) public onlyMinter returns (bool) {
_mint(to, tokenId);
_setTokenURI(tokenId, tokenURI);
return true;
}
}