๐Ÿฅ—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.

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

Step 1: Create a Collection Contract

Create Collection

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.

Verify Collection

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.

Step 2: Create an Object in your Collection Contract

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.

Upload to IPFS

  1. You will need to upload the images to an IPFS/NFT storage like https://nft.storage/ or Arweave.

  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/",

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.

Create an Object in Collection Contract

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!

Step 3: Craft a Craft Recipe

In this step, we will be creating a Craft Recipe by interacting with the UGCCraftLogic smart contract.

What is a Craft Recipe

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 tokenTypes:

  • 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

  "tokenAddress": "0x27996B7f37a5455E41aE6292fd00d21df1Fb82f1",
  "tokenId": 1,
  "amount": 1

Creating a Craft Recipe

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.

Step 4: Set Crafting Permissions in your Created Collection Contract

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.

List of Polygon Contracts




Last updated