Skip to main content
Version: Next

ABI Build Process

This document explains how ABI generation works during the Rust build process for Calimero applications.

Overview

The ABI generation process follows a two-step flow:

  1. Generate ABI at build time as JSON - The build process analyzes your Rust code and generates a JSON Schema-based ABI
  2. Optionally embed into WASM - The ABI can be embedded into the WASM binary for tools that may load/swap different WASMs

Build Script

Create a simple build.rs file:

use calimero_abi_emitter::emit_manifest;

fn main() {
emit_manifest().expect("Failed to generate ABI manifest");
}

Type Mapping

Rust types are automatically mapped to ABI-compatible representations:

Rust TypeABI TypeNotes
u8, u16, u32, u64u8, u16, u32, u64Direct mapping
i8, i16, i32, i64i8, i16, i32, i64Direct mapping
boolboolDirect mapping
StringstringUTF-8 string
Vec<T>list<T>Dynamic array
[T; N]array<T, N>Fixed-size array
Option<T>T?Nullable type
Result<T, E>TSuccess type only
BTreeMap<K, V>map<K, V>Key-value mapping
HashMap<K, V>map<K, V>Key-value mapping
struct S { ... }record S { ... }Record type
enum E { ... }variant E { ... }Variant type

ABI Extraction

Use the calimero-abi tool to extract the ABI from your WASM binary:

calimero-abi extract target/wasm32-unknown-unknown/release/my_app.wasm

Next Steps

Was this page helpful?
Need some help? Check Support page