(data.primaryNetwork.blocks)
- getBlockById - Get block
- listPrimaryNetworkBlocksByNodeId - List blocks proposed by node
- listLatestPrimaryNetworkBlocks - List latest blocks
Gets a block by block height or block hash on one of the Primary Network chains.
import { AvaCloudSDK } from "@avalabs/avacloud-sdk";
const avaCloudSDK = new AvaCloudSDK({
apiKey: "<YOUR_API_KEY_HERE>",
chainId: "43114",
network: "mainnet",
});
async function run() {
const result = await avaCloudSDK.data.primaryNetwork.blocks.getBlockById({
blockchainId: "p-chain",
blockId: "5615di9ytxujackzaXNrVuWQy5y8Yrt8chPCscMr5Ku9YxJ1S",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { dataPrimaryNetworkBlocksGetBlockById } from "@avalabs/avacloud-sdk/funcs/dataPrimaryNetworkBlocksGetBlockById.js";
// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
apiKey: "<YOUR_API_KEY_HERE>",
chainId: "43114",
network: "mainnet",
});
async function run() {
const res = await dataPrimaryNetworkBlocksGetBlockById(avaCloudSDK, {
blockchainId: "p-chain",
blockId: "5615di9ytxujackzaXNrVuWQy5y8Yrt8chPCscMr5Ku9YxJ1S",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.GetBlockByIdRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
options.serverURL |
string | ➖ | An optional server URL to use. |
Promise<components.GetPrimaryNetworkBlockResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.BadRequest | 400 | application/json |
errors.Unauthorized | 401 | application/json |
errors.Forbidden | 403 | application/json |
errors.NotFound | 404 | application/json |
errors.TooManyRequests | 429 | application/json |
errors.InternalServerError | 500 | application/json |
errors.BadGateway | 502 | application/json |
errors.ServiceUnavailable | 503 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Lists the latest blocks proposed by a given NodeID on one of the Primary Network chains.
import { AvaCloudSDK } from "@avalabs/avacloud-sdk";
const avaCloudSDK = new AvaCloudSDK({
apiKey: "<YOUR_API_KEY_HERE>",
chainId: "43114",
network: "mainnet",
});
async function run() {
const result = await avaCloudSDK.data.primaryNetwork.blocks.listPrimaryNetworkBlocksByNodeId({
startTimestamp: 1689541049,
endTimestamp: 1689800249,
pageSize: 10,
blockchainId: "p-chain",
nodeId: "NodeID-111111111111111111116DBWJs",
});
for await (const page of result) {
// Handle the page
console.log(page);
}
}
run();
The standalone function version of this method:
import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { dataPrimaryNetworkBlocksListPrimaryNetworkBlocksByNodeId } from "@avalabs/avacloud-sdk/funcs/dataPrimaryNetworkBlocksListPrimaryNetworkBlocksByNodeId.js";
// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
apiKey: "<YOUR_API_KEY_HERE>",
chainId: "43114",
network: "mainnet",
});
async function run() {
const res = await dataPrimaryNetworkBlocksListPrimaryNetworkBlocksByNodeId(avaCloudSDK, {
startTimestamp: 1689541049,
endTimestamp: 1689800249,
pageSize: 10,
blockchainId: "p-chain",
nodeId: "NodeID-111111111111111111116DBWJs",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
for await (const page of result) {
// Handle the page
console.log(page);
}
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.ListPrimaryNetworkBlocksByNodeIdRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
options.serverURL |
string | ➖ | An optional server URL to use. |
Promise<operations.ListPrimaryNetworkBlocksByNodeIdResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.BadRequest | 400 | application/json |
errors.Unauthorized | 401 | application/json |
errors.Forbidden | 403 | application/json |
errors.NotFound | 404 | application/json |
errors.TooManyRequests | 429 | application/json |
errors.InternalServerError | 500 | application/json |
errors.BadGateway | 502 | application/json |
errors.ServiceUnavailable | 503 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Lists latest blocks on one of the Primary Network chains.
import { AvaCloudSDK } from "@avalabs/avacloud-sdk";
const avaCloudSDK = new AvaCloudSDK({
apiKey: "<YOUR_API_KEY_HERE>",
chainId: "43114",
network: "mainnet",
});
async function run() {
const result = await avaCloudSDK.data.primaryNetwork.blocks.listLatestPrimaryNetworkBlocks({
startTimestamp: 1689541049,
endTimestamp: 1689800249,
pageSize: 10,
blockchainId: "p-chain",
});
for await (const page of result) {
// Handle the page
console.log(page);
}
}
run();
The standalone function version of this method:
import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { dataPrimaryNetworkBlocksListLatestPrimaryNetworkBlocks } from "@avalabs/avacloud-sdk/funcs/dataPrimaryNetworkBlocksListLatestPrimaryNetworkBlocks.js";
// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
apiKey: "<YOUR_API_KEY_HERE>",
chainId: "43114",
network: "mainnet",
});
async function run() {
const res = await dataPrimaryNetworkBlocksListLatestPrimaryNetworkBlocks(avaCloudSDK, {
startTimestamp: 1689541049,
endTimestamp: 1689800249,
pageSize: 10,
blockchainId: "p-chain",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
for await (const page of result) {
// Handle the page
console.log(page);
}
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.ListLatestPrimaryNetworkBlocksRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
options.serverURL |
string | ➖ | An optional server URL to use. |
Promise<operations.ListLatestPrimaryNetworkBlocksResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.BadRequest | 400 | application/json |
errors.Unauthorized | 401 | application/json |
errors.Forbidden | 403 | application/json |
errors.NotFound | 404 | application/json |
errors.TooManyRequests | 429 | application/json |
errors.InternalServerError | 500 | application/json |
errors.BadGateway | 502 | application/json |
errors.ServiceUnavailable | 503 | application/json |
errors.SDKError | 4XX, 5XX | */* |