Skip to content

Commit

Permalink
Updated NFT
Browse files Browse the repository at this point in the history
  • Loading branch information
aminlatifi committed Aug 21, 2024
1 parent e846ad4 commit 02eb0f9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 3 additions & 1 deletion script/QAccProjectNFT.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ contract QAccProjectNFTScript is Script {
function run() public {
vm.startBroadcast();

nft = new QAccProjectNFT("QAccProjectNFT", "QAPNFT");
address deployer = tx.origin;

nft = new QAccProjectNFT("QAccProjectNFT", "QAPNFT", deployer, "BaseURI");

vm.stopBroadcast();
}
Expand Down
20 changes: 19 additions & 1 deletion src/QAccProjectNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ import "@openzeppelin/contracts/access/Ownable.sol";

contract QAccProjectNFT is ERC721, Ownable {
uint256 private _nextTokenId;
string private _baseTokenURI;

constructor(string memory name, string memory symbol) ERC721(name, symbol) Ownable(msg.sender) {
constructor(string memory name, string memory symbol, address initialOwner, string memory baseURI)
ERC721(name, symbol)
Ownable(initialOwner)
{
_nextTokenId = 1; // Start token IDs at 1
_setBaseURI(baseURI);
}

function mint(address to) external onlyOwner {
Expand All @@ -20,4 +25,17 @@ contract QAccProjectNFT is ERC721, Ownable {
function currentTokenId() external view returns (uint256) {
return _nextTokenId - 1;
}

// set base URI
function setBaseURI(string memory baseURI) external onlyOwner {
_setBaseURI(baseURI);
}

function _setBaseURI(string memory baseURI) internal {
_baseTokenURI = baseURI;
}

function _baseURI() internal view override returns (string memory) {
return _baseTokenURI;
}
}

0 comments on commit 02eb0f9

Please sign in to comment.