-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNFTcollectionContract.sol
More file actions
55 lines (33 loc) · 1.24 KB
/
NFTcollectionContract.sol
File metadata and controls
55 lines (33 loc) · 1.24 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
contract NFTcollectionContract{
uint256 public nextTokenId;
address private _owner;
string private Name = "EnthuNFT";
string private Symbol = "ETU";
mapping(uint256 => address) private owners;
mapping(uint256 => string) private tokenURIs;
mapping(address => uint256) private balances;
constructor(){
_owner = msg.sender;
}
error dontHavePermission();
modifier onlyOwner(){
require(msg.sender == _owner, dontHavePermission());
_;
}
event Transfer(address indexed from, address indexed to, uint256 tokenId);
function name() external view returns (string memory){ return Name; }
function symbol() external view returns (string memory){ return Symbol; }
function tokenURI(uint256 tokenId) external view returns (string memory){
return tokenURIs[tokenId];
}
function mintNFT(string memory uri) public onlyOwner{
uint256 tokenId = nextTokenId;
nextTokenId++;
owners[tokenId] = msg.sender;
balances[msg.sender]++;
tokenURIs[tokenId] = uri;
emit Transfer(address(0), msg.sender, tokenId);
}
}