Gra Fun
  • 🤩Welcome to GraFun
  • 📈Fair Curve
    • 🔄BNB redemption
    • 👑Meme DAO
  • 📊Classic curve
  • 🎯Alpha Launch
  • 🚀 How to Launch
    • 🏦 Service Fees
  • 🛠️Tech Guide
    • 🔄IPFS Cache Data Upload and Synchronization Guide
    • 🧩CID Format
  • ⚖️Terms of Use
Powered by GitBook
On this page
  • Uploading Files to IPFS
  • Supported File Formats
  • CID Format
  • Creating Metadata JSON
  • Synchronizing Files with IPFS Cache
  • Accessing Content
  • CID format Conversion Guide (node js)
  1. Tech Guide

IPFS Cache Data Upload and Synchronization Guide

This guide outlines the steps required to upload and synchronize data in the IPFS cache, ensuring compatibility with the frontend.


Uploading Files to IPFS

You can use any uploader or service to upload files and JSON metadata to IPFS.


Supported File Formats

Currently, the frontend supports the following avatar file formats:

  • .gif

  • .jpg

Ensure the uploaded file meets these format requirements.


CID Format

After uploading a file, the service will return a CID (Content Identifier). IPFS supports multiple CID formats. Our frontend supports CID v1 (base32), which looks like this:

bafybeigxhwjaljyquoltsz7o6qq24npbk2diz2s43wsxl6dqagne3qvnsq

Avoid using the older CID v0 format, which appears as:

QmcprpP6Sc3LY4x4BDbGNo1k5e3CwcDRCNmaZ9kX6GLnAo

For more details on CIDs, refer to:


Creating Metadata JSON

Once the CID is obtained and formatted to CID v1 (base32), you need to create a JSON structure to store the metadata required by the frontend.

The metadata format is similar to OpenSea standards:

Example JSON (refer to this sample when creating own json):

Differences from OpenSea Format:

  • image: The CID of the uploaded image in CID v1 (base32) format + the file extension (e.g., .jpg or .gif).

  • description: Should not contain special characters and must be limited to 256 characters.


Synchronizing Files with IPFS Cache

After adding the image CID to the JSON and uploading the JSON to IPFS, synchronize both files (image + JSON) with the IPFS cache.

API Request for Synchronization

URL: https://api.dexe.io/integrations/ipfs-cache-svc/public/pool-info

Method: POST

Headers:

{
  https://maps.app.goo.gl/MRBNG11Hs66srAEP6"Content-Type": "application/json"
}

Body:

{
  "data": {
    "attributes": {
      "link": "your_cid_here"
    }
  }
}

Accessing Content

Once synchronized, the content will be accessible and viewable on the frontend. You can verify it using the following GET requests:

JSON Metadata:

https://ipfs-cache.dexe.io/<json_cid>.json

Example:

https://ipfs-cache.dexe.io/bafybeiapxtj7d65qwu6byb3twjt4fpdqmkw4ilagsqc3zdgpzplxzbtunu.json

Image File:

https://ipfs-cache.dexe.io/<image_cid>.<extension>

Example:

https://ipfs-cache.dexe.io/bafybeidfdzuvo7ostazu3sw65mmmf46vo6h3fa5qxeqmo56gwqsndvduo4.jpg


By following this guide, your data will be correctly uploaded, synchronized, and ready for frontend integration.

CID format Conversion Guide (node js)

import { CID } from 'multiformats/cid' 
import { base32 } from 'multiformats/bases/base32'
async function convertCID(oldCID) { 
    try { 
        // Parse the old CID 
        const parsed = CID.parse(oldCID)

        // Create new CIDv1 in base32
        const newCID = parsed.toV1()

        // Convert to base32 string
        return newCID.toString(base32)
    } catch (error) {
        console.error('Error converting CID:', error)
        throw error
    }
}

// Usage example
async function main() {
    const oldCID = 'QmdfLnJ22TFRPdvqKMirjxgVVRassP9Si8YqpK6nbBcZDw'
    try {
        const newCID = await convertCID(oldCID)
        console.log('Old CID:', oldCID)
        console.log('New CIDv1 (Base32):', newCID)
    } catch (error) {
        console.error('An error occurred:', error)
    } 
}
main()
PreviousTech GuideNextCID Format

Last updated 5 months ago

🛠️
🔄
IPFS Content Addressing
CID Specification
OpenSea Metadata Standards
Sample JSON