Upload JSON to IPFS
Upload JSON metadata to IPFS for use in atom creation. Returns the IPFS hash, name, and size.
Mutation Structureβ
mutation UploadJsonToIpfs($json: jsonb!) {
uploadJsonToIpfs(json: $json) {
hash
name
size
}
}
Variablesβ
| Variable | Type | Required | Description |
|---|---|---|---|
json | jsonb | Yes | JSON object to upload |
{
"json": {
"name": "Ethereum",
"description": "A decentralized blockchain platform",
"image": "ipfs://QmXnnyufdzAWL5CqZ2RnSNgPbvCc1ALT73s6epPrRnZ1Xy",
"url": "https://ethereum.org",
"type": "Thing"
}
}
Response Fieldsβ
| Field | Type | Description |
|---|---|---|
hash | String! | IPFS content hash (CID) |
name | String! | Filename on IPFS |
size | String! | File size |
Expected Responseβ
{
"data": {
"uploadJsonToIpfs": {
"hash": "QmYx8C3kNN1sFSx5bZPyN1sFSx5b8MqKu2r6CTSJ",
"name": "metadata.json",
"size": "256"
}
}
}
Interactive Exampleβ
Query
mutation UploadJsonToIpfs($json: jsonb!) {
uploadJsonToIpfs(json: $json) {
hash
name
size
}
}Variables
Click "Run Query" to execute the GraphQL query and see results
Common Metadata Schemasβ
Thing Schemaβ
{
"name": "Ethereum",
"description": "A decentralized blockchain platform that enables smart contracts",
"image": "ipfs://Qm...",
"url": "https://ethereum.org"
}
Person Schemaβ
{
"name": "Vitalik Buterin",
"description": "Co-founder of Ethereum",
"image": "ipfs://Qm...",
"email": "vitalik@ethereum.org",
"identifier": "vitalik.eth",
"url": "https://vitalik.ca"
}
Organization Schemaβ
{
"name": "Ethereum Foundation",
"description": "Non-profit supporting Ethereum development",
"image": "ipfs://Qm...",
"url": "https://ethereum.foundation",
"email": "info@ethereum.org"
}
Use Casesβ
Complete Atom Creation Workflowβ
Upload metadata and use the IPFS hash for atom creation:
import { GraphQLClient } from 'graphql-request'
import { API_URL_PROD } from '@0xintuition/graphql'
const client = new GraphQLClient(API_URL_PROD)
async function prepareAtomMetadata(thing: {
name: string
description: string
image: string
url?: string
}) {
const mutation = `
mutation UploadJsonToIpfs($json: jsonb!) {
uploadJsonToIpfs(json: $json) {
hash
name
size
}
}
`
const result = await client.request(mutation, { json: thing })
return result.uploadJsonToIpfs.hash
}
Relatedβ
- Upload Image - Upload images
- Upload Image from URL - Import external images
- Pin Thing - Pin Thing metadata
- Pin Person - Pin Person metadata
- Pin Organization - Pin Organization metadata