# CID Format

## 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()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gra.fun/tech-guide/cid-format.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
