interface ApiOptions {
    cacheMetadata?: boolean;
    cacheStorage?: IStorage;
    hasher?: HashFn;
    metadata?: Record<`RAW_META/${string}`, `0x${string}`>;
    provider: JsonRpcProvider;
    runtimeApis?: Record<string, RuntimeApiSpec[]>;
    scaledResponses?: Record<string, $.AnyShape>;
    signedExtensions?: Record<string, AnySignedExtension>;
    signer?: Signer;
    subscriptions?: SubscriptionsInfo;
    throwOnUnknownApi?: boolean;
}

Hierarchy (view full)

Properties

cacheMetadata?: boolean
cacheStorage?: IStorage
hasher?: HashFn

Customize hashing algorithm used

blake2_256
metadata?: Record<`RAW_META/${string}`, `0x${string}`>

Metadata is usually downloaded from chain via RPC upon API initialization, We can supply the metadata directly via this option to skip the download metadata step.

Metadata Key format: RAW_META/{genesisHash}/{runtimeSpecVersion}

If the genesisHash & runtimeSpecVersion of the supplied metadata key match with connected chain, then use the provided metadata, else we fetch it anew from chain.

provider: JsonRpcProvider

A JSON-RPC provider instance, it could be a WsProvider or SmoldotProvider

runtimeApis?: Record<string, RuntimeApiSpec[]>

Custom runtime api definitions/specs

You probably don't need to use this with the latest Metadata V15, unless you're connecting to a chain supports only Metadata V14

scaledResponses?: Record<string, $.AnyShape>
signedExtensions?: Record<string, AnySignedExtension>

User-defined chain-specific signed extensions

signer?: Signer

A signer instance to use for signing transactions

subscriptions?: SubscriptionsInfo
throwOnUnknownApi?: boolean

By default, an UnknownApiError error will be thrown out if an api is known (e.g: api.query.pallet.unknown) upon evaluation. When set this to false, the api evaluation will simply return undefined

true