Estos son los NFTs más Justos
https://youtu.be/pu_tp4d8ii0
Antes de comenzar
Para este tutorial ocuparás Metamask u otra 지갑 호환 con fondos en Goerli que puedes obtener desde un faucet .
엘 스마트 계약
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
import '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
contract MyWhitelistNFT is ERC721Enumerable, Ownable {
uint256 public price = 0.01 ether;
uint256 public constant MAX_SUPPLY = 10000;
string public baseTokenURI = "https://baseurl.com/";
bool public saleActive = false;
mapping (address => uint256) public whitelistReserved;
constructor () ERC721 ("My MNFT", "MNFT") {
}
// Overide functions
function _baseURI() internal view virtual override returns (string memory) {
return baseTokenURI;
}
// Public functions
function mintToken(uint256 _amount) public payable {
uint256 supply = totalSupply();
require( supply + _amount <= MAX_SUPPLY, "Can't mint more than max supply" );
require( msg.value == price * _amount, "Wrong amount of ETH sent" );
if(!saleActive)
{
uint256 reservedAmt = whitelistReserved[msg.sender];
require(reservedAmt > 0 && _amount <= reservedAmt, "Sale isn't active and you are not whitelisted" );
whitelistReserved[msg.sender] = reservedAmt - _amount;
}
for(uint256 i; i < _amount; i++){
_safeMint( msg.sender, supply + i );
}
}
// Admin functions
function editWhitelistReserved(address[] memory _a, uint256[] memory _amount) public onlyOwner {
for(uint256 i; i < _a.length; i++){
whitelistReserved[_a[i]] = _amount[i];
}
}
function setSaleActive(bool val) public onlyOwner {
saleActive = val;
}
function setBaseURI(string memory baseURI) public onlyOwner {
baseTokenURI = baseURI;
}
function withdraw() public payable onlyOwner {
(bool sent, bytes memory data) = owner().call{value: address(this).balance}("");
data;
require(sent, "Failed to send Ether");
}
}
Gracias por ver este 비디오!
Sígannos en dev.to y en para todo lo relacionado al desarrollo en Blockchain en Español.
Reference
이 문제에 관하여(Estos son los NFTs más Justos), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/turupawn/estos-son-los-nfts-mas-justos-1np8텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)