-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathW8day2.sol
More file actions
60 lines (33 loc) · 1.28 KB
/
W8day2.sol
File metadata and controls
60 lines (33 loc) · 1.28 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
56
57
58
59
60
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
contract W8NFT{
uint256 public nextTokenId;
mapping(uint256 => address) private owners;
mapping(uint256 => string) private tokenURIs;
mapping(address => uint256) private balances;
event Transfer(address indexed from, address indexed to, uint256 tokenId);
function name() external view returns (string memory){}
function symbol() external view returns (string memory){}
function tokenURI(uint256 tokenId) external view returns (string memory){
return tokenURIs[tokenId];
}
function mintNFT(string memory uri) public{
uint256 tokenId = nextTokenId;
nextTokenId++;
owners[tokenId] = msg.sender;
balances[msg.sender]++;
tokenURIs[tokenId] = uri;
emit Transfer(address(0), msg.sender, tokenId);
}
function bacthMintNFT(string[] memory uri) public{
uint256 uris = uri.length;
for(uint256 i = 0; i < uris; i++){
uint256 tokenId = nextTokenId;
nextTokenId++;
owners[tokenId] = msg.sender;
balances[msg.sender]++;
tokenURIs[tokenId] = uri[i];
emit Transfer(address(0), msg.sender, tokenId);
}
}
}