Skip to content

Instantly share code, notes, and snippets.

@rgottleber
Created April 10, 2025 18:52
Show Gist options
  • Select an option

  • Save rgottleber/742c290a639fb164b27e53cd89fd654f to your computer and use it in GitHub Desktop.

Select an option

Save rgottleber/742c290a639fb164b27e53cd89fd654f to your computer and use it in GitHub Desktop.
April Bootcamp NFT
// SPDX-License-Identifier: MIT
// Compatible with OpenZeppelin Contracts ^5.0.0
pragma solidity ^0.8.22;
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import {ERC721URIStorage} from "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
contract BloomsCollection is ERC721, ERC721URIStorage, Ownable {
uint256 private _nextTokenId;
string private constant DEFAULT_URI = "https://ipfs.io/ipfs/QmYaTsyxTDnrG4toc8721w62rL4ZBKXQTGj9c9Rpdrntou/purple-blooms.json";
constructor(address initialOwner)
ERC721("BloomsCollection", "BLOOM")
Ownable(initialOwner)
{}
function safeMint(address to)
public
onlyOwner
returns (uint256)
{
uint256 tokenId = _nextTokenId++;
_safeMint(to, tokenId);
_setTokenURI(tokenId, DEFAULT_URI);
return tokenId;
}
// Maintain original function for flexibility
function safeMint(address to, string memory uri)
public
onlyOwner
returns (uint256)
{
uint256 tokenId = _nextTokenId++;
_safeMint(to, tokenId);
_setTokenURI(tokenId, uri);
return tokenId;
}
// The following functions are overrides required by Solidity.
function tokenURI(uint256 tokenId)
public
view
override(ERC721, ERC721URIStorage)
returns (string memory)
{
return super.tokenURI(tokenId);
}
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721, ERC721URIStorage)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment