Create Your ERC721 Contract
Install Dependencies
forge install openzeppelin/openzeppelin-contracts openzeppelin-contracts=lib/openzeppelin-contractsimport "openzeppelin-contracts/contracts/token/ERC721/ERC721.sol";The ERC721 Contract
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "openzeppelin-contracts/contracts/token/ERC721/ERC721.sol";
import "openzeppelin-contracts/contracts/access/Ownable.sol";
contract MyNFT is ERC721, Ownable{
string private _URIBase;
constructor(string memory name_, string memory symbol_) ERC721(name_, symbol_) {
_transferOwnership(msg.sender);
}
function mint(address to, uint256 tokenId) public onlyOwner {
_safeMint(to, tokenId);
}
function setBaseURI(string memory baseURI_) public onlyOwner {
_URIBase = baseURI_;
}
function _baseURI() internal view override returns (string memory) {
return _URIBase;
}
}Deploy Your ERC721 Contract
Mint An NFT
Last updated