01 · Contract
Contract của bạn.
Toàn bộ contract ERC-721 của AvaxCats. Bấm Deploy là nó lên Fuji Testnet (43113) bằng ví của bạn — không cần Remix, không cần cài gì.
contracts/AvaxCats.solsolc 0.8.365,677 bytes20 hàm publicĐã compile
| 1 | // SPDX-License-Identifier: MIT |
| 2 | pragma solidity ^0.8.20; |
| 3 | |
| 4 | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; |
| 5 | |
| 6 | contract AvaxCats is ERC721URIStorage { |
| 7 | |
| 8 | uint256 public constant COLLECTION_SIZE = 48; |
| 9 | |
| 10 | uint256 public constant MAX_SUPPLY = COLLECTION_SIZE; |
| 11 | |
| 12 | uint256 public totalMinted; |
| 13 | mapping(uint256 => bool) public catMinted; |
| 14 | mapping(uint256 => uint256) public catOf; |
| 15 | |
| 16 | event Minted(address indexed to, uint256 indexed tokenId, uint256 indexed catId); |
| 17 | |
| 18 | error CatDoesNotExist(uint256 catId); |
| 19 | error CatAlreadyMinted(uint256 catId); |
| 20 | |
| 21 | constructor() ERC721("AvaxCats - Team1 VN", "ACAT") {} |
| 22 | |
| 23 | function mint(uint256 catId, string memory uri) external returns (uint256) { |
| 24 | if (catId >= COLLECTION_SIZE) revert CatDoesNotExist(catId); |
| 25 | if (catMinted[catId]) revert CatAlreadyMinted(catId); |
| 26 | |
| 27 | catMinted[catId] = true; |
| 28 | uint256 tokenId = ++totalMinted; |
| 29 | catOf[tokenId] = catId; |
| 30 | |
| 31 | _safeMint(msg.sender, tokenId); |
| 32 | _setTokenURI(tokenId, uri); |
| 33 | emit Minted(msg.sender, tokenId, catId); |
| 34 | return tokenId; |
| 35 | } |
| 36 | |
| 37 | function mintedBitmap() external view returns (uint256 bits) { |
| 38 | for (uint256 i; i < COLLECTION_SIZE; ++i) { |
| 39 | if (catMinted[i]) bits |= (1 << i); |
| 40 | } |
| 41 | } |
| 42 | } |
Kết nối ví để deploy.
Deploy tốn khoảng 1,25 triệu gas. Xin AVAX test ở faucet