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 pictures: PNG, JPEG, WebP and GIF. The server checks the file's bytes, not its declared type or name, and picks the stored file name itself.
  • 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. Pass the returned cid to POST /api/v1/me/profile as { "avatar": "<cid>" } from the same wallet to use it.

Response

Response
{
  "url": "https://cyan-abundant-swordtail-589.mypinata.cloud/ipfs/bafy...",
  "cid": "bafy..."
}
200 Upload successful400 No file / empty or too large / not a PNG, JPEG, WebP or GIF / 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;
}