# Network
(*network*)
## Overview
### Available Operations
* [networkList](#networklist) - Get List of Available Networks
* [networkStatus](#networkstatus) - Get Network Status
* [networkOptions](#networkoptions) - Get Network Options
## networkList
This endpoint returns a list of NetworkIdentifiers that the Rosetta server supports.
### Example Usage
```typescript
import { Icpmcp } from "icpmcp-rosetta-api";
const icpmcp = new Icpmcp({
serverURL: "https://api.example.com",
});
async function run() {
const result = await icpmcp.network.networkList({});
console.log(result);
}
run();
```
### Standalone function
The standalone function version of this method:
```typescript
import { IcpmcpCore } from "icpmcp/core.js";
import { networkNetworkList } from "icpmcp/funcs/networkNetworkList.js";
// Use `IcpmcpCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const icpmcp = new IcpmcpCore({
serverURL: "https://api.example.com",
});
async function run() {
const res = await networkNetworkList(icpmcp, {});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("networkNetworkList failed:", res.error);
}
}
run();
```
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request` | [models.MetadataRequest](../../models/metadatarequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
### Response
**Promise\<[models.NetworkListResponse](../../models/networklistresponse.md)\>**
### Errors
| Error Type | Status Code | Content Type |
| ------------------------- | ------------------------- | ------------------------- |
| errors.ErrorT | 500 | application/json |
| errors.IcpmcpDefaultError | 4XX, 5XX | \*/\* |
## networkStatus
This endpoint returns the current status of the network requested. Any NetworkIdentifier returned by /network/list should be accessible here.
### Example Usage
```typescript
import { Icpmcp } from "icpmcp-rosetta-api";
const icpmcp = new Icpmcp({
serverURL: "https://api.example.com",
});
async function run() {
const result = await icpmcp.network.networkStatus({
networkIdentifier: {
blockchain: "bitcoin",
network: "mainnet",
subNetworkIdentifier: {
network: "shard 1",
metadata: {},
},
},
});
console.log(result);
}
run();
```
### Standalone function
The standalone function version of this method:
```typescript
import { IcpmcpCore } from "icpmcp/core.js";
import { networkNetworkStatus } from "icpmcp/funcs/networkNetworkStatus.js";
// Use `IcpmcpCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const icpmcp = new IcpmcpCore({
serverURL: "https://api.example.com",
});
async function run() {
const res = await networkNetworkStatus(icpmcp, {
networkIdentifier: {
blockchain: "bitcoin",
network: "mainnet",
subNetworkIdentifier: {
network: "shard 1",
metadata: {},
},
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("networkNetworkStatus failed:", res.error);
}
}
run();
```
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request` | [models.NetworkRequest](../../models/networkrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
### Response
**Promise\<[models.NetworkStatusResponse](../../models/networkstatusresponse.md)\>**
### Errors
| Error Type | Status Code | Content Type |
| ------------------------- | ------------------------- | ------------------------- |
| errors.ErrorT | 500 | application/json |
| errors.IcpmcpDefaultError | 4XX, 5XX | \*/\* |
## networkOptions
This endpoint returns the version information and allowed network-specific types for a NetworkIdentifier. Any NetworkIdentifier returned by /network/list should be accessible here. Because options are retrievable in the context of a NetworkIdentifier, it is possible to define unique options for each network.
### Example Usage
```typescript
import { Icpmcp } from "icpmcp-rosetta-api";
const icpmcp = new Icpmcp({
serverURL: "https://api.example.com",
});
async function run() {
const result = await icpmcp.network.networkOptions({
networkIdentifier: {
blockchain: "bitcoin",
network: "mainnet",
subNetworkIdentifier: {
network: "shard 1",
metadata: {},
},
},
});
console.log(result);
}
run();
```
### Standalone function
The standalone function version of this method:
```typescript
import { IcpmcpCore } from "icpmcp/core.js";
import { networkNetworkOptions } from "icpmcp/funcs/networkNetworkOptions.js";
// Use `IcpmcpCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const icpmcp = new IcpmcpCore({
serverURL: "https://api.example.com",
});
async function run() {
const res = await networkNetworkOptions(icpmcp, {
networkIdentifier: {
blockchain: "bitcoin",
network: "mainnet",
subNetworkIdentifier: {
network: "shard 1",
metadata: {},
},
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("networkNetworkOptions failed:", res.error);
}
}
run();
```
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request` | [models.NetworkRequest](../../models/networkrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
### Response
**Promise\<[models.NetworkOptionsResponse](../../models/networkoptionsresponse.md)\>**
### Errors
| Error Type | Status Code | Content Type |
| ------------------------- | ------------------------- | ------------------------- |
| errors.ErrorT | 500 | application/json |
| errors.IcpmcpDefaultError | 4XX, 5XX | \*/\* |