The Canonical ABI is a standard calling convention for packaging and translating values across a WebAssembly boundary. It lets a Wasm component communicate with a host or another Wasm guest without a custom data contract. section 2.4 section 4.0
WebAssembly Interface Types (WIT) describes richer interface values, while the Canonical ABI lifts those values into the interface layer and lowers them back to core Wasm representations. This replaces manually encoding complex values in linear memory. section 2.4 section 4.0
The interface-level values supported by this arrangement include:
- Primitive values such as booleans, integers, floating-point numbers, characters, and strings. section 2.4
- Compound values such as lists, options, results, tuples, records, enums, variants, flags, aliases, and functions. section 2.4
- Values copied into and out of memory as they cross the Wasm boundary. section 2.4
A string-based component interface
A WIT world can declare an exported function as `export greet: func(name: string) -> string;`. The interface describes the operation and its string values; the Canonical ABI defines how those values cross between the component and its host. section 2.4
Listing 2.4 The ”Hello, World” application’s WIT
package component:hello-world-guest-wit;
world example {
export greet: func(name: string) -> string;
}
Inspect the complete WIT definition for the Hello World component interface. section 2.4
