├── NFT_Source_code.sol └── README.md /NFT_Source_code.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; 5 | import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol"; 6 | import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; 7 | import "@openzeppelin/contracts/utils/math/SafeMath.sol"; 8 | import "@openzeppelin/contracts/access/Ownable.sol"; 9 | import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; 10 | 11 | /** 12 | * @title 哔哩哔哩:二娃玩转区块链 13 | * 微信:zxmeng1999 14 | */ 15 | contract StudyNft is ERC721Enumerable, Ownable, ReentrancyGuard { 16 | using SafeMath for uint256; 17 | 18 | bool public isSaleActive = false; 19 | string public PROVENANCE = "-"; 20 | uint public constant maxMintBatch = 20; 21 | uint256 public constant tokenPrice = 10000000000000000; // 你要出售的价格0.01 ETH 22 | uint256 public maxTokensCount = 11111; 23 | address[] private distributions; 24 | string private baseURI; 25 | string public baseTokenURI; 26 | string public contractURI; 27 | 28 | constructor() ERC721("erwaplayblockchain", "BLO") { 29 | baseURI = "ipfs://QmUEJzKyAH8mXXsActmiWrjJgYL8kV6ffPAX9qMvBaHpvz/"; // 填写您的baseURI 30 | baseTokenURI = "https://angelicrealm.angelsofaether.com/aoagencontif4hw377/AngelsOfAetherGeneral.json"; 31 | contractURI = ""; 32 | } 33 | 34 | function setDistributions(address[] memory _distributions) public onlyOwner { 35 | distributions = _distributions; 36 | } 37 | 38 | function getDistributions() public onlyOwner view returns (address[] memory) { 39 | return distributions; 40 | } 41 | 42 | function activateSale() public onlyOwner { 43 | isSaleActive = true; 44 | } 45 | 46 | function deactivateSale() public onlyOwner { 47 | isSaleActive = false; 48 | } 49 | 50 | function setBaseTokenURI(string memory uri) public onlyOwner { 51 | baseTokenURI = uri; 52 | } 53 | 54 | function setContractURI(string memory uri) public onlyOwner { 55 | contractURI = uri; 56 | } 57 | 58 | function _baseURI() internal view override returns (string memory) { 59 | return baseURI; 60 | } 61 | 62 | function setBaseURI(string memory uri) public onlyOwner { 63 | baseURI = uri; 64 | } 65 | 66 | function setPROVENANCE(string memory prov) public onlyOwner { 67 | PROVENANCE = prov; 68 | } 69 | 70 | function distribute(uint256 requestedSum) public onlyOwner { 71 | require(distributions.length > 1, "Distributions cannot be empty"); 72 | uint balance = address(this).balance; 73 | require(balance > requestedSum, "Requesting too much"); 74 | 75 | uint share = requestedSum / distributions.length; 76 | for (uint i = 0; i < distributions.length; i++) { 77 | payable(distributions[i]).transfer(share); 78 | } 79 | } 80 | 81 | function withdraw() public onlyOwner { 82 | uint balance = address(this).balance; 83 | payable(msg.sender).transfer(balance); 84 | } 85 | 86 | function reserveAngelsOfAether() public onlyOwner { 87 | uint supply = totalSupply(); 88 | uint i; 89 | for (i = 0; i < maxMintBatch; i++) { 90 | _safeMint(msg.sender, supply + i); 91 | } 92 | } 93 | 94 | function mint(uint numberOfTokens) public payable { 95 | require(isSaleActive, "Sale must be active to be able to mint"); 96 | require(numberOfTokens <= maxMintBatch, "Max 20 tokens can be minted in one batch"); 97 | require(totalSupply().add(numberOfTokens) <= maxTokensCount, "Purchase would exceed max supply of Tokens"); 98 | require(tokenPrice.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct"); 99 | 100 | for(uint i = 0; i < numberOfTokens; i++) { 101 | uint mintIndex = totalSupply(); 102 | if (totalSupply() < maxTokensCount) { 103 | _safeMint(msg.sender, mintIndex); 104 | } 105 | } 106 | } 107 | 108 | function burn(uint256 tokenId) public onlyOwner { 109 | _burn(tokenId); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### NFT源码项目使用指南🧭 2 | 3 | - 复制源码文件 nft_source_code.sol 4 | - 粘贴到 http://remix.ethereum.org/ 5 | - 编译项目 6 | - 部署项目(ETH、Polygon) 7 | - 调用 activateSale() 开始mint 8 | - 选择 mint 填写 wei的数量 9 | 10 | 11 | --- 12 | 视频教程:https://linktr.ee/erwaplayblockchain 13 | 14 | 作者更多内容: 15 | ➡️ 进discord 更多优质内容 : https://discord.com/invite/RHtf7V6Z5G (快讯推送,每日优质资料爬取,分类聊天。一站式服务) 16 | 17 | [discord社群展示](https://s4.ax1x.com/2022/01/22/7fpMTA.png) 18 | 开发+答疑 微信:zxmeng1999 19 | --------------------------------------------------------------------------------