-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathW8day1.sol
More file actions
67 lines (42 loc) · 1.61 KB
/
W8day1.sol
File metadata and controls
67 lines (42 loc) · 1.61 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
61
62
63
64
65
66
67
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
contract ERC721Basics{
string public name = "firtsNFT";
string public symbol = "fNFT";
mapping(uint256 => address) private owners;
mapping(address => uint256) private balances;
uint256 public nextTokenId;
//Core functions
function ownerOf(uint256 tokenId) public view returns(address){
return owners[tokenId];
}
function balanceOf(address owner) public view returns(uint256){
return balances[owner];
}
function mintNFT() public{
uint256 tokenId = nextTokenId;
nextTokenId++;
owners[tokenId] = msg.sender;
balances[msg.sender]++;
emit Transfer(address(0), msg.sender, tokenId);
}
function batchMint(uint256 quantity) public {
for(uint256 i = 0; i < quantity; i++){
uint256 tokenId = nextTokenId;
nextTokenId++;
owners[tokenId] = msg.sender;
balances[msg.sender]++;
emit Transfer(address(0), msg.sender, tokenId);
}
}
function transferFrom(address from, address to, uint256 tokenId) public returns(bool){
balances[from] -= tokenId;
balances[to] += tokenId;
emit Transfer(from, to, tokenId);
return true;
}
function approve(address spender, uint256 tokenId) public{}
//Two important events
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approveal(address indexed owner, address indexed approved, uint256 indexed tokenId);
}