Once we have imported PHX network, lets deploy a tokenized ERC721 contract!
Note: We will be using OpenZeppelin SDK (https://docs.openzeppelin.com/) for this example.
Here is an example of our Rare Thing ERC721 contract:
// contracts/RareThing.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import “@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol”;
import “@openzeppelin/contracts/utils/Counters.sol”;
contract RareThing is ERC721URIStorage {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
constructor() ERC721(“RareThing”, “RT”) {}
function awardItem(address player, string memory tokenURI)
public
returns (uint256)
{
uint256 newItemId = _tokenIds.current();
_mint(player, newItemId);
_setTokenURI(newItemId, tokenURI);
_tokenIds.increment();
return newItemId;
}
}
Here is an example of Metadata tokenURI in JSON document:
{
“name”: “Golden Duck”,
“image”: “IPFS-URL_GOES_HERE”,
“description”: “The brightest of Ducks gleaming in the sunlight”,
“external_url”: “EXTERNAL_URL_GOES_HERE, like your website or social media account”,
“attributes”: [
{
“value”: “Golden Worthy”,
“trait_type”: “Rarity”
},
{
“value”: “Golden Laser Eyes”,
“trait_type”: “Weapon”
},
{
“value”: “Golden Shoulder Pads”,
“trait_type”: “Armor”
},
{
“value”: “Golden Shine”,
“trait_type”: “Style”
}
],
“artist”: “ARTIST_NAME_GOES_HERE”
}
For a list of full commands available on ERC 721, reference: https://eips.ethereum.org/EIPS/eip-721