🥗UGC Craft
Phi UGC Craft Creation Flow
Last updated
Phi UGC Craft Creation Flow
Last updated
Phi introduces a unique way for users to craft advanced objects. With Phi Craft, you can create your own UGC Craft Recipe with your own Phi UGC Objects.
This guide requires knowledge on:
using an IPFS storage to store NFT images and NFT Metadata
interacting with smart contracts directly using a tool like Polygonscan
In this step, we will be creating a UGC NFT Collection Contract to hold UGC Objects. We will be interacting with the UGCCraftableObjectFactory smart contract to achieve this.
Navigate to the UGCCraftableObjectFactory smart contract and execute the Execute the createUGCCraftableObject function. You will need to decide on the following parameters:
_name: The name of your collection. This is similar to OpenSea's NFT Collection name.
_symbol: The symbol representing your collection. This is similar to an ERC-712/ERC-1155 token name.
Example of a successful transaction: https://polygonscan.com/tx/0xa49db77dcefe3fc69d69cdc6ca9b823ba687122dbff2f804e0aff3c9309cfb17
You may verify that the Collection Contract was created successfully by calling the getDeployedUGCCraftableObjects function in the same smart contract with your deployer address.
A list of all the Collections created by the address will be returned.
In this step, we will be uploading an Image and NFT Metadata using your preferred IPFS storage and then create an Object (NFT) in the Collection created in Step 1.
You will need to upload the images to an IPFS/NFT storage like https://nft.storage/ or Arweave.
Then, using the link to your NFT images, create and upload the NFT Metadata in JSON format to the same storage to receive the URL. The minimum information needed are as follows:
Note: You may also add additional metadata as per OpenSea's Metadata Standards.
Hold on to the URL to the NFT Metadata for the next step.
Navigate to the Collection Contract created in Step 1 and execute the createObject
function.
tokenUri - the NFT Metadata URL.
maxClaimable - The amount of this object can be crafted.
Do not use the NFT Image URL for this step!
Example of a successful transaction: https://polygonscan.com/tx/0xe3e515f855a57107c41c9fa59774fab3fdf11fc68720883d0884dbce458647f0
In this step, we will be creating a Craft Recipe by interacting with the UGCCraftLogic smart contract.
A Craft Recipe is a set of logic in order to craft/claim a UGC Object. There are 3 components to a Craft Recipe:
Materials This is the ingredients to a Craft Recipe - Phi Materials, Phi Craft Objects, and Phi UGC Objects are currently the acceptable NFTs. At least one material must be defined. Materials will be consumed/burned when the Craft Recipe is used.
You may enter a list of materials in the following format:
Catalyst This is the condition that must be fulfilled in order to use the Craft Recipe. There are 3 supported catalysts:
ERC-20 balance - e.g. Holds Polygon USDC $1000
ERC-721 balance - e.g. Holds a Lens Handle
ERC-1155 balance - e.g. Holds a specific Phi Quest Object NFT (tokenId 100001)
You may also choose not to define a catalyst by entering the following parameter:
There are 3 tokenType
s:
0
- for ERC-20 tokens
1
- for ERC-721 tokens
2
- for ERC-1155 tokens
Only Polygon smart contracts are supported!
Artifacts This is the output/crafted Objects of the Craft Recipe - specifically this are the UGC Objects you have created in Step 2. You may define multiple Objects and quantity from the same Collection as well.
tokenAddress: The Collection Contract address
tokenId: The Object in the Collection to be crafted
amount: The number of the Objects to be crafted
Navigate to the createRecipe function in UGCCraftLogic and enter the details as shown above. When the Craft Recipe creation is successful, you will obtain a recipeId
.
Example of a successful transaction:
ERC-20 Catalyst: https://polygonscan.com/tx/0x7850b86f65213151efc4c9d253fcc45392e1a19b76128324b3b7deb4b7307ea1
ERC 721 Catalyst: https://polygonscan.com/tx/0x841373ac1aae42d5e2fb343eec3bc9fd63c17fd2ba44babf4d05ad4f47e053bd
ERC 1155 Catalyst: https://polygonscan.com/tx/0xebeb074b84d7a0fcd704d3eb34bab003841dbd84a985313d4881be057f6706eb
In this step, we will be enabling the Craft Recipe in the Collection Contract by allowing the Object to be crafted by the Craft Recipe. Craft Recipe will then appear in the Craft page.
Navigate to your Collection Contract and find the setApprovalForUGCCrafting
function with the following parameters:
tokenId - The reward Object's tokenId
recipeId - The Craft Recipe ID from Step 3.
approval - Set to true
to enable the Craft Recipe, or false
to disable.
Your Craft Recipe will appear in the Craft page when the transaction is submitted. Similarly, disabling the recipe will remove it in the Craft page.
Your new Craft Recipe may take up to an hour to appear in the Craft page.
Example of a successful transaction: https://polygonscan.com/tx/0xcc8ea5d9410d3ff40a016df41fe1a775dd0402cfc9bd18107e01408c2614ab84
0x8D851B86cD299f9020a529A0975365eCFc1048BB
0x7c79490391a5c0186018c0481c3cef67d7ea1186