TypedApi
The TypedApi allows to interact with the runtime metadata easily and with a great developer experience. It'll allow to make storage calls, create transactions, etc. It uses the descriptors generated by PAPI CLI (see Codegen section for a deeper explanation) to generate the types used at devel time. TypedApi object looks like:
type TypedApi = {
query: StorageApi
tx: TxApi
event: EvApi
apis: RuntimeCallsApi
constants: ConstApi
txFromCallData: TxFromBinary
getStaticApis: (options?: {
at?: HexString | "finalized" | "best"
signal?: AbortSignal
}) => Promise<StaticApis>
}Every field except for getStaticApis and txFromCallData is a Record<string, Record<string, ???>>. The first index defines the pallet, and the second one defines which query/tx/event/api/constant within that pallet. Each one of them will be described in the following pages.
txFromCallData will be explained as well in the tx section. getStaticApis() returns a promise that resolves once the runtime is loaded, providing synchronous access to constants, compatibility checks, and transaction encoding. See the Static APIs for details.