Javascript Anchor Types Reference
This reference shows you how anchor maps rust types to javascript/typescript types in the client.
Rust Type | Javascript Type | Example | Note |
---|---|---|---|
bool | bool |
|
|
u64/u128/i64/i128 | anchor.BN |
|
https://github.com/indutny/bn.js/ |
u8/u16/u32/i8/i16/i32 | number |
|
|
f32/f64 | number |
|
|
Option<T> | null or T |
|
|
Enum | { variantName: {} } |
|
No support for tuple variants |
Struct | { val: {} } |
|
No support for tuple structs |
[T; N] | [ T ] |
|
|
String | string |
|
|
Vec<T> | [ T ] |
|