Content
Image Upload
Uploads an image to IPFS via Pinata. Used when creating tokens or prediction markets. Images should be resized to 512x512 WebP before uploading for best results.
POST
/api/images
Uploads an image file to IPFS. Requires a purpose field to determine validation rules.
Auth: Session or API Key
Request
Content-Type: multipart/form-data
- Field:
file— the image file - Field:
purpose—"token"or"avatar"(required) - Field:
address— token contract address (required when purpose is"token") - Allowed types:
image/jpeg,image/png,image/webp,image/gif - Max file size: 5 MB
- Token: caller must be the on-chain DEV/creator of the ecosystem token
- Avatar: limited to 5 uploads per calendar month
Response
Response
{
"url": "https://cyan-abundant-swordtail-589.mypinata.cloud/ipfs/bafy...",
"cid": "bafy..."
}200 Upload successful400 No file / invalid type / missing purpose401 Not authenticated403 Not ecosystem token / not creator429 Avatar monthly limit reached503 RPC unavailable
Example Code
// Upload an image (requires authenticated session)
async function uploadImage(imageFile, sessionCookie) {
const formData = new FormData();
formData.append("file", imageFile);
// FormData must include: file, purpose ("token" or "avatar"), address (for token purpose)
formData.append("purpose", "token");
formData.append("address", "0xTokenAddress...");
const res = await fetch("https://launchonbasis.com/api/images", {
method: "POST",
headers: { "Cookie": sessionCookie },
body: formData,
});
const { url, cid } = await res.json(); // Returns { url: "https://...ipfs/...", cid: "bafkrei..." }
return url;
}