References
Javascript Anchor Types Reference
This reference shows you how Anchor maps Rust types to JavaScript/TypeScript types in the client.
Type | Rust | TypeScript | Example |
---|---|---|---|
Boolean | bool | boolean |
|
Integer | u8/u16/u32/i8/i16/i32 | number |
|
Big integer | u64/u128/i64/i128 | anchor.BN |
|
Float | f32/f64 | number |
|
String | String | string |
|
Array | [T; N] | Array<T> |
|
Vector | Vec<T> | Array<T> |
|
Option | Option<T> | T | null | undefined | None :
Some(val) :
|
Struct | Struct | object |
|
Enum | Enum | object | Unit variant: Named variant: Unnamed (tuple) variant:
|