SDK Types
Custom Types
All types used in the SDK are exported via two ways.
Classes
The first is via a JavaScript class. These will always begin with a capital letter. This class will always have the core functions below. Other specific functions may also be implemented.
The .convert() function is especially useful when dealing with different NumberTypes (bigint -> string).
Interfaces
The second is a JavaScript interface. This is the same as the class version minus all functions (just the core JSON object).
Which one to use?
Many functions support both; however, you may have to convert between them occasionally for compatibility. We recommend using the classes, but we recognize that many developers prefer the interfaces.
Typed Arrays
Some types also have a typed array exported as well. Similar to a Uint8Array in Javascript, these have all the features of traditional arrays. Thus, you can use .find, .map, .filter(), etc. Plus, additional functions will be available on them (e.g. array.addBalances for the BalanceArray type).
Proto Types
Some might have duplicates between the two types.
The Proto types are exported via the following
If you ever end up with something like the following, this is also the proto definition. We recommend using the proto.abc.xyz method to avoid confusion.
Last updated