Comment on page
🥗
UGC Craft
Phi UGC Craft Creation Flow
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.

Components of a UGC Craft Recipe
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.

Smart contract function to create a Collection
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.

List of Collections created by the deployer address
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.
- 1.
- 2.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:
{
name: "Cubo",
collection: {
name: "PHI - UGC Craftable Object",
},
image: "https://bafkreiehtfsekl42r4uslafy3uyfqpudswrdgt4yqfrfvstrs7tw2yt45u.ipfs.nftstorage.link/",
}
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!

Create an Object with the NFT metadata URI
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:
[{
"tokenAddress": "0x27996B7f37a5455E41aE6292fd00d21df1Fb82f1",
"tokenId": 100001,
"amount": 1
},{
...
}]
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
{"tokenAddress": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", "tokenId": 0, "amount": 1000, "tokenType": 0}
ERC-721 balance - e.g. Holds a Lens Handle
{"tokenAddress": "0xdb46d1dc155634fbc732f92e853b10b288ad5a1d", "tokenId": 0, "amount": 1, "tokenType": 1}
ERC-1155 balance - e.g. Holds a specific Phi Quest Object NFT (tokenId 100001)
{"tokenAddress": "0x3D8C06e65ebf06A9d40F313a35353be06BD46038", "tokenId": 100001, "amount": 1, "tokenType": 2}
You may also choose not to define a catalyst by entering the following parameter:
{"tokenAddress": "0x0000000000000000000000000000000000000000", "tokenId": 0, "amount": 0, "tokenType": 0}
There are 3
tokenType
s:0
- for ERC-20 tokens1
- for ERC-721 tokens2
- 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
[{
"tokenAddress": "0x27996B7f37a5455E41aE6292fd00d21df1Fb82f1",
"tokenId": 1,
"amount": 1
},{
...
}]
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
.
Creating a Craft Recipe
Example of a successful transaction:
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, orfalse
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.

Allow the Object to be crafted by the Craft Recipe
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
Name | Address |
---|---|
0x8D851B86cD299f9020a529A0975365eCFc1048BB | |
0x7c79490391a5c0186018c0481c3cef67d7ea1186 |
Last modified 1mo ago