-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pokedex42.sol
38 lines (33 loc) · 1.47 KB
/
Pokedex42.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// contracts/Pokedex42.sol
// SPDX-License-Identifier: MIT
/**
* @title Pokedex42
* @dev This contract allows the owner to mint unique ERC-721 tokens representing Pok←mon.
* Each token has a unique ID and associated metadata (e.g., the Pok←mon's details).
* The owner can assign these tokens to different players, effectively "catching" Pok←mon on their behalf.
* The contract is based on the ERC721 standard with URI storage and ownership management.
*/
pragma solidity ^0.8.20;
// Importing necessary OpenZeppelin contracts
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
// Contract for minting Pok←mon NFTs
contract Pokedex42 is ERC721URIStorage, Ownable {
uint256 private _nextTokenId;
constructor() ERC721("Pokedex42", "P42") Ownable(msg.sender) {}
/**
* @dev Mints a new Pok←mon NFT with a unique token ID and assigns it to the specified player.
* @param player Address of the player receiving the Pok←mon.
* @param tokenURI URI pointing to the Pok←mon's metadata.
* @return tokenId The ID of the newly minted Pok←mon.
*/
function PokemonCatch(
address player,
string memory tokenURI
) public onlyOwner returns (uint256) {
uint256 tokenId = _nextTokenId++;
_mint(player, tokenId);
_setTokenURI(tokenId, tokenURI);
return tokenId;
}
}