@acala-network/chopsticks-core • Docs
@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
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
Defined in
Properties
signedExtensions
readonly
signedExtensions:ExtDef
Defined in
Accessors
chain
get
chain():Promise
<string
>
Returns
Promise
<string
>
Defined in
chainProperties
get
chainProperties():Promise
<ChainProperties
>
Returns
Promise
<ChainProperties
>
Defined in
isReady
get
isReady():undefined
|Promise
<void
>
Returns
undefined
| Promise
<void
>
Defined in
Methods
disconnect()
disconnect():
Promise
<void
>
Returns
Promise
<void
>
Defined in
getBlock()
getBlock(
hash
?):Promise
<null
|SignedBlock
>
Parameters
• hash?: string
Returns
Promise
<null
| SignedBlock
>
Defined in
getBlockHash()
getBlockHash(
blockNumber
?):Promise
<null
| `0x${string}`>
Parameters
• blockNumber?: number
Returns
Promise
<null
| `0x${string}`>
Defined in
getHeader()
getHeader(
hash
?):Promise
<null
|Header
>
Parameters
• hash?: string
Returns
Promise
<null
| Header
>
Defined in
getKeysPaged()
getKeysPaged(
prefix
,pageSize
,startKey
,hash
?):Promise
<string
[]>
Parameters
• prefix: string
• pageSize: number
• startKey: string
• hash?: string
Returns
Promise
<string
[]>
Defined in
getStorage()
getStorage(
key
,hash
?):Promise
<null
| `0x${string}`>
Parameters
• key: string
• hash?: string
Returns
Promise
<null
| `0x${string}`>
Defined in
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
getSystemChain()
getSystemChain():
Promise
<string
>
Returns
Promise
<string
>
Defined in
getSystemName()
getSystemName():
Promise
<string
>
Returns
Promise
<string
>
Defined in
getSystemProperties()
getSystemProperties():
Promise
<ChainProperties
>
Returns
Promise
<ChainProperties
>
Defined in
onFetching()
onFetching(
fetching
?):void
Parameters
• fetching?
Returns
void
Defined in
send()
send<
T
>(method
,params
,isCacheable
?):Promise
<T
>
Type Parameters
• T = any
Parameters
• method: string
• params: unknown
[]
• isCacheable?: boolean
Returns
Promise
<T
>
Defined in
subscribeRemoteFinalizedHeads()
subscribeRemoteFinalizedHeads(
cb
):Promise
<string
|number
>
Parameters
• cb: ProviderInterfaceCallback
Returns
Promise
<string
| number
>
Defined in
subscribeRemoteNewHeads()
subscribeRemoteNewHeads(
cb
):Promise
<string
|number
>
Parameters
• cb: ProviderInterfaceCallback
Returns
Promise
<string
| number
>