Verified contractExactMIT
SimpleTestNFT
Address0xcce641c16df312db3b4f56ad07b213a2fa100c3f
- Balance
0 ETH
- Transactions
3
- Compiler
solc 0.8.30
- Same code
Only this contract
Details
- Compiler
- solc 0.8.30+commit.73712a01
- Language
- solidity
- Optimization
- No
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 23,905,062
- Creation transaction
- 0x31bd3ceab8…0816fa5871
contracts/TestNFT.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* Simple Test NFT Contract
* Deploy this to Sepolia testnet to create your own NFTs for testing
*/
contract SimpleTestNFT {
// Token name
string public name = "Test NFT Collection";
// Token symbol
string public symbol = "TNFT";
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping from token ID to token URI
mapping(uint256 => string) private _tokenURIs;
// Counter for token IDs
uint256 private _tokenIdCounter = 0;
// Event emitted when NFT is minted
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
function mint(string memory _tokenURI) public returns (uint256) {
_tokenIdCounter++;
uint256 newTokenId = _tokenIdCounter;
_owners[newTokenId] = msg.sender;
_tokenURIs[newTokenId] = _tokenURI; // use the new name
emit Transfer(address(0), msg.sender, newTokenId);
return newTokenId;
}
/**
* Standard ERC-721 ownerOf function
* This is what your backend calls to verify ownership
* @param tokenId Token ID to check
* @return address Owner of the token
*/
function ownerOf(uint256 tokenId) public view returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "Token does not exist");
return owner;
}
/**
* Get token URI (metadata)
* @param tokenId Token ID
* @return string Token URI
*/
function tokenURI(uint256 tokenId) public view returns (string memory) {
require(_owners[tokenId] != address(0), "Token does not exist");
return _tokenURIs[tokenId];
}
/**
* Transfer NFT to another address
* @param to Recipient address
* @param tokenId Token ID to transfer
*/
function transfer(address to, uint256 tokenId) public {
require(_owners[tokenId] == msg.sender, "You don't own this token");
require(to != address(0), "Invalid recipient");
_owners[tokenId] = to;
emit Transfer(msg.sender, to, tokenId);
}
/**
* Get total number of minted tokens
*/
function totalSupply() public view returns (uint256) {
return _tokenIdCounter;
}
}Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.