forked from PennCIS233/Practical-HW1
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcontract-source.sol
More file actions
35 lines (26 loc) · 1.15 KB
/
contract-source.sol
File metadata and controls
35 lines (26 loc) · 1.15 KB
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
//Contract based on [https://docs.openzeppelin.com/contracts/3.x/erc721](https://docs.openzeppelin.com/contracts/3.x/erc721)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
contract IntroToBlockchainNFT is ERC721URIStorage, Ownable {
uint256 private tokenNo;
string private URI = "ipfs://bafkreidjaecmjth2n3dricle3nxr6hhrhqfvwce4q5gx4w2ol5bydufyv4";
constructor() ERC721("IntroToBlockchainNFT", "CIS2330NFT") {}
function mintNFT() public isInAddressBook(msg.sender) {
require (tokenNo +1 > tokenNo);
tokenNo++;
uint256 newItemId = tokenNo;
_mint(msg.sender, newItemId);
_setTokenURI(newItemId, URI);
}
mapping (address => string) public AddressBook ;
function enterAddressIntoBook(string memory name) public {
AddressBook[msg.sender] = name;
}
modifier isInAddressBook(address addr) {
require (bytes(AddressBook[addr]).length > 0);
_;
}
}