What is this?
Every Chonk is a voxel model stored on-chain on Base. The body and each equipped Trait are lists of colored voxels on the same grid.
The Chonks indexer serves a ready-to-render model for any Chonk. One GET request gives you the voxels with the Traits already layered, so you only need to draw cubes.
This page tells you, or the agent writing your code, how to fetch a Chonk, what the data means, and how to put it in a scene. If you want a Chonk that walks, waves, and jumps, skip to Rig And Animate With RigKit.
Quick Start
const res = await fetch("https://indexer.chonks.xyz/chonk/27543/3d");
const { success, chonk, error } = await res.json();
if (!success) throw new Error(error);
for (const { x, y, z, color } of chonk.voxels) {
// Draw one 1×1×1 cube at (x, y, z) in `color`.
// See Coordinates for how to place it in your world.
}
That is the whole integration. The rest of this page explains the fields and the conventions.
Get A 3D Chonk
GET https://indexer.chonks.xyz/chonk/:chonkId/3d
curl https://indexer.chonks.xyz/chonk/27543/3d
- No API key and no wallet
chonkIdis the decimal token ID, such as27543- The response is JSON
{
"success": true,
"chonk": {
"tokenId": 27543,
"owner": "0x…",
"layerOrder": ["body", "shoes", "bottom", "top", "hair", "face", "head", "accessory"],
"traits": [
{ "layer": "shoes", "name": "Shoes White" },
{ "layer": "bottom", "name": "Suspender Shorts Black" },
{ "layer": "top", "name": "Lost Sweater Dark" },
{ "layer": "face", "name": "Shades" },
{ "layer": "head", "name": "Baseball Cap Black" },
{ "layer": "accessory", "name": "Red Balloon" }
],
"accessory": "Red Balloon",
"bodyIndex": 2,
"backgroundColor": "7b939d",
"zMap": "0b1705ba8136…",
"voxelCount": 534,
"voxels": [
{ "x": 11, "y": 23, "z": 5, "color": "#ffffff" },
…
],
"bounds": {
"min": { "x": 9, "y": 6, "z": 3 },
"max": { "x": 26, "y": 23, "z": 8 }
},
"updatedAtBlock": 37916337
}
}
Response Fields
voxels: what you draw. One entry per visible cell.coloris#rrggbb, ready fornew THREE.Color(color)or any CSS-style color parservoxelCount: the length ofvoxelsbounds: the smallest and largestx,yandzinvoxels. Use it to center the model or fit the camerazMap: the same model as one hex string, in layer order, before layering is applied. Pass it to tools that take a zMap, such as RigKit. See The zMap FormatlayerOrder: the layers from bottom to top. It is always the same eight valuestraits: the equipped Traits, inlayerOrder. An empty slot is left out, so a Chonk with no hat has noheadentryaccessory: the Accessory Trait name, ornull. RigKit uses it to keep a hand on a held itembodyIndex: the skin tone,0to4backgroundColor: the Chonk's background color as 6 hex characters with no#. Useful for a matching scene backgroundowner: the current owner, EIP-55 checksummedupdatedAtBlock: the Base block the Traits in the model were last read at
Errors
Errors use one shape:
{ "success": false, "code": "NOT_FOUND", "error": "The indexer has no 3D model for Chonk #999999." }
INVALID_CHONK_ID(HTTP 400): the ID is not a decimal numberNOT_FOUND(HTTP 404): no Chonk has that IDQUERY_FAILED(HTTP 500): the indexer had a problem. Retry after a short wait
Branch on
code, not on the error text.What Is Already Done For You
The endpoint does this work before it responds, so your code does not have to:
- Layering. Traits are applied in render order. Where a Trait covers the body or a lower Trait, only the outer voxel is in
voxels. About a quarter of a dressed Chonk's raw voxels are hidden this way - Normalizing.
zMapis plain lowercase hex with no0x. You never need to decode hex-encoded ASCII - Body tone. The body layer always matches
bodyIndex, including after an owner changes skin tone - Trait names.
traitsandaccessorycome from the Chonk's metadata, so you do not need to decode the tokenURI - No chain reads. Everything comes from the indexer. You do not need an RPC endpoint or a wallet
What you still do yourself: build the mesh, place it in your world, light it, and animate it if you want to.
The zMap Format
A zMap is a hex string. Every 12 hex characters (6 bytes) is one voxel:
0b 17 05 ef b1 5e
x y z r g b
x,y,z: one byte each, the grid cellr,g,b: one byte each, the color. The example voxel is#efb15eatx = 11,y = 23,z = 5
To parse it yourself:
function parseZMap(zMap: string) {
const cells = new Map<string, { x: number; y: number; z: number; color: string }>();
for (let i = 0; i + 12 <= zMap.length; i += 12) {
const x = parseInt(zMap.slice(i, i + 2), 16);
const y = parseInt(zMap.slice(i + 2, i + 4), 16);
const z = parseInt(zMap.slice(i + 4, i + 6), 16);
const color = `#${zMap.slice(i + 6, i + 12)}`;
cells.set(`${x},${y},${z}`, { x, y, z, color }); // a later voxel replaces an earlier one
}
return [...cells.values()];
}
You only need this if you take
zMap instead of voxels, or read a zMap from somewhere else. The parser must let a later voxel replace an earlier one in the same cell. If it keeps the first voxel instead, the body shows through clothes.Layer Order
The zMap lists the layers bottom first, in the same order as the on-chain renderer and the 2D art:
- Body
- Shoes
- Bottom
- Top
- Hair
- Face
- Head
- Accessory
Each voxel has its own
x, y, z, so order only matters when two layers fill the same cell. Then the later layer wins: a Top covers the body, and a Head item covers Hair. voxels already has this applied.Coordinates
The grid is 30 × 30 cells across and high, and a few cells deep.
xruns left to right as you look at the Chonk's face. The middle column isx = 14yruns top to bottom. The feet are on rowy = 23zruns back to front. A largerzis nearer the front, where the face is
Most engines have Y pointing up, so flip
y. To stand the Chonk on the ground at the origin, facing +Z, with 1-unit cubes:const position = {
x: voxel.x - 14.5,
y: 23 - voxel.y + 0.5,
z: voxel.z - 5.5,
};
The
+ 0.5 puts each cube's center inside its cell, so the soles sit on y = 0. Scale the whole model afterward. RigKit uses 0.075 world units per voxel, which makes a Chonk about 1.8 units tall.Render In three.js
This builds one merged mesh and skips every face that touches another voxel. One mesh draws fast, and no lines show between cubes.
import * as THREE from "three";
const FACES = [
{ n: [1, 0, 0], c: [[1, 0, 0], [1, 1, 0], [1, 1, 1], [1, 0, 1]] },
{ n: [-1, 0, 0], c: [[0, 0, 1], [0, 1, 1], [0, 1, 0], [0, 0, 0]] },
{ n: [0, 1, 0], c: [[0, 1, 1], [1, 1, 1], [1, 1, 0], [0, 1, 0]] },
{ n: [0, -1, 0], c: [[0, 0, 0], [1, 0, 0], [1, 0, 1], [0, 0, 1]] },
{ n: [0, 0, 1], c: [[1, 0, 1], [1, 1, 1], [0, 1, 1], [0, 0, 1]] },
{ n: [0, 0, -1], c: [[0, 0, 0], [0, 1, 0], [1, 1, 0], [1, 0, 0]] },
];
export async function loadChonkMesh(chonkId: number, voxelSize = 0.075) {
const res = await fetch(`https://indexer.chonks.xyz/chonk/${chonkId}/3d`);
const { success, chonk, error } = await res.json();
if (!success) throw new Error(error);
// World cells: x right, y up, z toward the viewer.
const cells = chonk.voxels.map((v) => ({
x: v.x - 15,
y: 23 - v.y,
z: v.z - 6,
color: new THREE.Color(v.color),
}));
const filled = new Set(cells.map((c) => `${c.x},${c.y},${c.z}`));
const positions: number[] = [];
const normals: number[] = [];
const colors: number[] = [];
const indices: number[] = [];
for (const cell of cells) {
for (const face of FACES) {
const [nx, ny, nz] = face.n;
if (filled.has(`${cell.x + nx},${cell.y + ny},${cell.z + nz}`)) continue;
const start = positions.length / 3;
for (const [cx, cy, cz] of face.c) {
positions.push(cell.x + cx, cell.y + cy, cell.z + cz);
normals.push(nx, ny, nz);
colors.push(cell.color.r, cell.color.g, cell.color.b);
}
indices.push(start, start + 1, start + 2, start, start + 2, start + 3);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
geometry.setAttribute("normal", new THREE.Float32BufferAttribute(normals, 3));
geometry.setAttribute("color", new THREE.Float32BufferAttribute(colors, 3));
geometry.setIndex(indices);
const mesh = new THREE.Mesh(geometry, new THREE.MeshStandardMaterial({ vertexColors: true }));
mesh.scale.setScalar(voxelSize);
return { mesh, chonk };
}
Here each cell's corner is at the integer position, so the cube spans
x to x + 1. The Chonk stands on y = 0, centered on x = 0, and faces +Z. Point a camera at it from +Z.For a quick test, an
InstancedMesh of BoxGeometry with one instance per voxel also works. It is simpler, but thin lines can show between cubes.Other 3D Engines
The data is engine-agnostic. In any engine:
- GET
/chonk/:chonkId/3d - For each entry in
voxels, place a unit cube using the mapping in Coordinates. Flipyif your engine's Y points up. Swap axes if your engine is Z-up - Color each cube from
color - Merge the cubes into one mesh and drop faces between neighbors if the engine does not do it for you
Notes per engine:
- Babylon.js: build a
MeshfromVertexDatawith the same face loop as the three.js example. Babylon is left-handed, so negatez. Negating one axis mirrors the mesh and turns the faces inside out, so also reverse the order of each face's corners - Unity: Y is up and the coordinates are left-handed. Negate
zso the Chonk faces a default camera, and reverse the order of each face's corners for the same reason as Babylon. Build oneMeshwith vertex colors - Godot: Y is up, right-handed like three.js. Build an
ArrayMeshwithSurfaceTooland vertex colors - Blender, MagicaVoxel and other tools: convert
voxelsto the tool's voxel format, or export the three.js mesh withGLTFExporterto a.glband import that - Game engines that load glTF: export once with
GLTFExporterand load the.glblike any other model
Rig And Animate With RigKit
RigKit (
rigkit-threejs on npm) turns a zMap into a rigged, animated Chonk for three.js. It is the Chonk from the Chonks Playground, with no React or wallet code. Its only dependency is three.npm install rigkit-threejs three
import * as THREE from "three";
import { ChonkRig, ChonkAnimator } from "rigkit-threejs";
const res = await fetch("https://indexer.chonks.xyz/chonk/27543/3d");
const { chonk } = await res.json();
const rig = new ChonkRig({ zMap: chonk.zMap, accessory: chonk.accessory });
scene.add(rig.object);
const animator = new ChonkAnimator(rig);
animator.play("walk"); // "idle" | "walk" | "run" | "jump" | "wave" | "bow"
const timer = new THREE.Timer();
renderer.setAnimationLoop((time) => {
timer.update(time);
animator.update(timer.getDelta());
renderer.render(scene, camera);
});
What RigKit does:
- Splits the voxels into bones: torso, body, both arms, both legs and both feet
- Keeps an arm still when the Accessory is held in that hand, such as a balloon or a sword. Pass
accessoryfor this - Faces +Z, stands on
y = 0, and is about 1.8 units tall at the defaultvoxelSizeof0.075 - Includes
BASE_BODIESinrigkit-threejs/bodies, the five bare bodies, so you can show a Chonk with no network request
RigKit also has
fetchChonk(tokenId), which reads the older /chonk/zmap endpoint. Prefer passing chonk.zMap from /chonk/:chonkId/3d, because that zMap is normalized and its body always matches bodyIndex.The animations do not move the Chonk through the world. Move
rig.object yourself, and play "jump" while your code lifts it. Read the RigKit README for the bone names, posing, and a React Three Fiber example.Other Endpoints
GET /chonk/owner/:address: the Chonks a wallet owns. Use theidof each row with/chonk/:chonkId/3dGET /chonk/:chonkId/traits: one row per Trait in the Chonk's Backpack, with that Trait's ownzMap,colorMapandanimationData3d. Use it to draw a single Trait or to animate Traits that move in 3D. A Trait's ownzMapcan be hex-encoded ASCII, so decode it before parsingGET /chonk/zmap?tokenId=1&tokenId=2: the raw stored zMaps for several Chonks in one request. These are not normalized or layered, so prefer/chonk/:chonkId/3dfor rendering
All of them are on
https://indexer.chonks.xyz.Agent Checklist
If you are an agent building this for a user:
- Ask the user which Chonk IDs to show. Do not walk ID ranges
- Use
/chonk/:chonkId/3dand drawvoxels. Do not re-implement layering - Flip
y. The grid'sygrows downward - Merge cubes into one mesh for anything beyond a quick test
- Cache the response per Chonk. A model only changes when its owner changes Traits or skin tone
- Do not read the chain or ask the user for an RPC key. The indexer has everything
- For a walking or animated Chonk in three.js, use RigKit