Skip to content

Language neutrality

A reusable capability block's code is Python, and its interface is expressed in XCI's own types. The interface is what crosses the block's boundary, so it is the one description that the Rust kernel, other blocks and your Python code all read. Inside the block you keep using any Python library you like.

Why the interface has its own types

  1. The kernel reads it. The kernel is written in Rust and checks every call against the interface before the call reaches your code.
  2. Callers come from anywhere. A workflow step, another block, or a block on another runtime provider calls your methods through the interface, whatever it was written in.
  3. A value means one thing. Every XCI type states its size and unit: u64 is an unsigned 64-bit integer, a decimal states its precision and scale, and a timestamp states its unit. A Python int or float carries none of that, so two callers could otherwise read the same value differently.

One interface, code for each side

The block pipeline compiles your block's interface once and generates code for each side of the boundary. A charge request in the ledger block becomes a Python class your block uses:

@dataclass(frozen=True, slots=True)
class ChargeRequest:
    account: str  # field id 1
    amount: int  # field id 2

and the matching Rust type the kernel side uses:

pub struct ChargeRequest {
    pub account: String, // field id 1
    pub amount: i128, // field id 2
}

Both come from the one interface, and both are regenerated whenever the interface changes, so the two sides always agree. See Generated bindings.

What stays in Python

Only what crosses the interface is typed in XCI. A DataFrame, a model, or a client session stays inside the block that created it, and callers receive typed values. See Any Python library and Framework objects.