Skip to content

@acala-network/chopsticks-coreDocs


@acala-network/chopsticks-core / Api

Class: Api

API class. Calls provider to get on-chain data. Either endpoint or genesis porvider must be provided.

Example

ts
const provider = new WsProvider(options.endpoint)
const api = new Api(provider)
await api.isReady

Constructors

new Api()

new Api(provider, signedExtensions?): Api

Parameters

provider: ProviderInterface

signedExtensions?: ExtDef

Returns

Api

Defined in

packages/core/src/api.ts:33

Properties

signedExtensions

readonly signedExtensions: ExtDef

Defined in

packages/core/src/api.ts:27

Accessors

chain

get chain(): Promise<string>

Returns

Promise<string>

Defined in

packages/core/src/api.ts:61


chainProperties

get chainProperties(): Promise<ChainProperties>

Returns

Promise<ChainProperties>

Defined in

packages/core/src/api.ts:68


isReady

get isReady(): undefined | Promise<void>

Returns

undefined | Promise<void>

Defined in

packages/core/src/api.ts:42

Methods

disconnect()

disconnect(): Promise<void>

Returns

Promise<void>

Defined in

packages/core/src/api.ts:38


getBlock()

getBlock(hash?): Promise<null | SignedBlock>

Parameters

hash?: string

Returns

Promise<null | SignedBlock>

Defined in

packages/core/src/api.ts:109


getBlockHash()

getBlockHash(blockNumber?): Promise<null | `0x${string}`>

Parameters

blockNumber?: number

Returns

Promise<null | `0x${string}`>

Defined in

packages/core/src/api.ts:97


getHeader()

getHeader(hash?): Promise<null | Header>

Parameters

hash?: string

Returns

Promise<null | Header>

Defined in

packages/core/src/api.ts:105


getKeysPaged()

getKeysPaged(prefix, pageSize, startKey, hash?): Promise<string[]>

Parameters

prefix: string

pageSize: number

startKey: string

hash?: string

Returns

Promise<string[]>

Defined in

packages/core/src/api.ts:128


getStorage()

getStorage(key, hash?): Promise<null | `0x${string}`>

Parameters

key: string

hash?: string

Returns

Promise<null | `0x${string}`>

Defined in

packages/core/src/api.ts:113


getStorageBatch()

getStorageBatch(prefix, keys, hash?): Promise<[`0x${string}`, null | `0x${string}`][]>

Parameters

prefix: `0x${string}`

keys: `0x${string}`[]

hash?: `0x${string}`

Returns

Promise<[`0x${string}`, null | `0x${string}`][]>

Defined in

packages/core/src/api.ts:146


getSystemChain()

getSystemChain(): Promise<string>

Returns

Promise<string>

Defined in

packages/core/src/api.ts:93


getSystemName()

getSystemName(): Promise<string>

Returns

Promise<string>

Defined in

packages/core/src/api.ts:85


getSystemProperties()

getSystemProperties(): Promise<ChainProperties>

Returns

Promise<ChainProperties>

Defined in

packages/core/src/api.ts:89


onFetching()

onFetching(fetching?): void

Parameters

fetching?

Returns

void

Defined in

packages/core/src/api.ts:76


send()

send<T>(method, params, isCacheable?): Promise<T>

Type Parameters

T = any

Parameters

method: string

params: unknown[]

isCacheable?: boolean

Returns

Promise<T>

Defined in

packages/core/src/api.ts:80


subscribeRemoteFinalizedHeads()

subscribeRemoteFinalizedHeads(cb): Promise<string | number>

Parameters

cb: ProviderInterfaceCallback

Returns

Promise<string | number>

Defined in

packages/core/src/api.ts:173


subscribeRemoteNewHeads()

subscribeRemoteNewHeads(cb): Promise<string | number>

Parameters

cb: ProviderInterfaceCallback

Returns

Promise<string | number>

Defined in

packages/core/src/api.ts:166