Meta Upload
Metadata fields
Field
Required
Notes
Upload (TypeScript with axios)
import axios from "axios";
import fs from "fs";
const UPLOAD_API = "https://funcs.flap.sh/api/upload";
const MUTATION_CREATE = `
mutation Create($file: Upload!, $meta: MetadataInput!) {
create(file: $file, meta: $meta)
}
`;
async function uploadTokenMeta(opts: {
imagePath: string;
description?: string;
twitter?: string;
telegram?: string;
website?: string;
}): Promise<string> {
const form = new FormData();
form.append(
"operations",
JSON.stringify({
query: MUTATION_CREATE,
variables: {
file: null,
meta: {
description: opts.description ?? "",
twitter: opts.twitter ?? null,
telegram: opts.telegram ?? null,
website: opts.website ?? null,
creator: "0x0000000000000000000000000000000000000000",
},
},
})
);
form.append("map", JSON.stringify({ "0": ["variables.file"] }));
const file = new File([fs.readFileSync(opts.imagePath)], "image.png", {
type: "image/png",
});
form.append("0", file);
const res = await axios.postForm(UPLOAD_API, form, {
headers: { "Content-Type": "multipart/form-data" },
});
if (res.status !== 200) {
throw new Error(`Upload failed: ${res.statusText}`);
}
// Returns the IPFS CID string — use this as the `meta` field in the token params.
return res.data.data.create as string;
}Last updated