Functions for querying the Kadena Chainweb blockchain API
- Source:
Namespaces
Methods
(inner) base64json(txt)
Decode base64url encoded JSON text
Parameters:
Name | Type | Description |
---|---|---|
txt |
string | base64url encoded json text |
- Source:
(inner) baseUrl(networkopt, hostopt, pathSuffix) → {Object}
Create URL for the Chainweb API
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
network |
string |
<optional> |
"mainnet01" | chainweb network |
host |
string |
<optional> |
"https://api.chainweb.com" | chainweb api host |
pathSuffix |
string | suffix of the path that is appended to the path of the base URL |
- Source:
Returns:
URL
- Type
- Object
(inner) chainUpdates(depth, chainIds, callback, networkopt, hostopt)
Apply callback to new updates.
Same as headerUpdates, but filters for chains and only processes header
updates that have reached the given confirmation depth in the chain.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
depth |
number | confirmation depth at which blocks are yielded | ||
chainIds |
Array.<number> | array of chainIds from which blocks are included | ||
callback |
blockCallback | function that is called for each update | ||
network |
string |
<optional> |
"mainnet01" | chainweb network |
host |
string |
<optional> |
"https://api.chainweb.com" | chainweb api host |
- Source:
Returns:
the event source object the backs the stream
(inner) chainUrl(chainId, networkopt, hostopt, pathSuffix) → {Object}
Create URL for a chain endpoint of the Chainweb API
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
chainId |
number | string | a chain id that is valid for the network | ||
network |
string |
<optional> |
"mainnet01" | chainweb network |
host |
string |
<optional> |
"https://api.chainweb.com" | chainweb api host |
pathSuffix |
string | suffix of the path that is appended to the path of the chain URL |
- Source:
Returns:
URL
- Type
- Object
(inner) filterEvents()
Utility function to filter the events from an array of blocks
- Source:
(inner) filterTxs()
Utility function to filter the transactions from an array of blocks
- Source:
(async, inner) headers2blocks()
Utility function for collecting the payloads with outputs for a set
of headers from the same chain.
TODO: Currently all blocks must be from the same chain. We should support
blocks from different chains.
TODO: The use of this function below is inefficient. It would be better
to start fetching payloads asynchronously while iterating through
block header pages.
- Source:
(inner) headerUpdates(callback, networkopt, hostopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
callback |
headerCallback | function that is called for each update | ||
network |
string |
<optional> |
"mainnet01" | chainweb network |
host |
string |
<optional> |
"https://api.chainweb.com" | chainweb api host |
- Source:
(async, generator, inner) pageItemIterator()
Yields flattened pages, i.e. individual page items are yielded.
- Source:
(async, generator, inner) pageIterator(query, nopt)
Yields full pages, i.e. arrarys of page items.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
query |
callback | A query callback that takes a `next` and an optional `limit` parameter. | |
n |
number |
<optional> |
Optional upper limit and the number of returned items. |
- Source:
(async, inner) retryFetch(retryOptionsopt) → {Promise}
Retry a fetch callback
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
retryOptions |
Object |
<optional> |
retry options object as accepted by the retry package
Properties
|
- Source:
Returns:
Promise object that represents the response of the fetch action.
- Type
- Promise
Type Definitions
blockCallback(block)
Callback for processing individual items of a block stream
Parameters:
Name | Type | Description |
---|---|---|
block |
Object | block object |
- Source:
eventCallback(event)
Callback for processing individual items of an event stream
Parameters:
Name | Type | Description |
---|---|---|
event |
Object | event object |
- Source:
headerCallback(header)
Callback for processing individual items of a header stream
Parameters:
Name | Type | Description |
---|---|---|
header |
Object | header object |
- Source:
transactionCallback(transaction)
Callback for processing individual items of a transaction stream
Parameters:
Name | Type | Description |
---|---|---|
transaction |
Object | transaction object |
- Source:
updatesCallback(update)
Callback for processing individual items of an updates stream
Parameters:
Name | Type | Description |
---|---|---|
update |
Object | update object |
- Source: