Creates an instance of SdlValidationError
.
The error message.
+Optional
stackStatic
Optional
prepareOptional override for formatting stack traces
+Static
stackRepresents a generic validation error.
+Extends the native Error
class.
Creates an instance of ValidationError
.
The error message.
+Optional
stackStatic
Optional
prepareOptional override for formatting stack traces
+Static
stackSDL (Stack Definition Language) parser and validator +Handles parsing and validation of Akash deployment manifests
+import { SDL } from './SDL';
const yaml = `
version: "2.0"
services:
web:
image: nginx
expose:
- port: 80
as: 80
to:
- global: true
`;
// Parse SDL from YAML string
const sdl = SDL.fromString(yaml);
// Get deployment manifest
const manifest = sdl.manifest();
// Get deployment groups
const groups = sdl.groups();
+
+
+Static
fromCreates an SDL instance from a YAML string.
+The YAML string containing the SDL definition.
+Optional
version: NetworkVersion = "beta2"The SDL version (beta2 or beta3).
+Optional
networkId: NetworkId = MAINNET_IDThe network ID to validate against.
+An instance of the SDL class.
+Static
validateStatic
validateGPUStatic
validateValidates the storage configuration for a given service.
+The name of the service.
+Optional
storage: v2ResourceStorage | v2ResourceStorageArrayThe storage resource configuration.
+Enum for Akash message types.
+Message type for closing a deployment.
+Message type for closing a group.
+Message type for creating a certificate.
+Message type for creating a deployment.
+Message type for creating a lease.
+Message type for depositing into a deployment.
+Message type for pausing a group.
+Message type for revoking a certificate.
+Message type for starting a group.
+Message type for updating a deployment.
+Broadcasts a certificate to the blockchain.
+The certificate PEM object.
+The owner of the certificate.
+The Stargate client used for signing and broadcasting.
+A promise that resolves to the transaction response.
+Creates a new certificate for a given Bech32 address.
+The Bech32 address for which to create the certificate.
+A promise that resolves to the deprecated certificate PEM object.
+Revokes a certificate on the blockchain.
+The owner of the certificate.
+The serial number of the certificate to revoke.
+The Stargate client used for signing and broadcasting.
+A promise that resolves to the transaction response.
+Connects to a blockchain endpoint with a given signer.
+The blockchain chain to connect to.
+The signer to use for the connection.
+The endpoint URL to connect to.
+A promise that resolves to the connected client.
+Returns the available blockchain chains.
+An object containing mainnet and testnet chain configurations.
+Creates a function to check the health status of an endpoint.
+The timeout duration for the health check request in milliseconds.
+A function that takes an endpoint object and returns a promise resolving to the endpoint's health status, including its address and response time.
+import { getEndpointHealthStatus, getEndpoints, NETWORK_TYPE, ENDPOINT_TYPE } from "@akashnetwork/akashjs/build/network";
const checkEndpointHealth = async () => {
try {
const endpoints = await getEndpoints(NETWORK_TYPE.MAINNET, ENDPOINT_TYPE.RPC);
const healthStatusPromises = endpoints.map(endpoint => getEndpointHealthStatus(800)(endpoint));
const healthStatuses = await Promise.all(healthStatusPromises);
console.log("Endpoint Health Statuses:");
healthStatuses.forEach(status => {
console.log(`Address: ${status.address}, Response Time: ${status.responseTime !== null ? status.responseTime + 'ms' : 'Unresponsive'}`);
});
} catch (error) {
console.error("Error checking endpoint health:", error);
}
};
checkEndpointHealth();
+
+
+Retrieves endpoints for a specific network and type.
+The network to get endpoints for.
+The type of endpoint to retrieve.
+A promise that resolves to an array of endpoint addresses.
+import { NETWORK_TYPE, ENDPOINT_TYPE, getEndpoints } from "@akashnetwork/akashjs/build/network";
async function fetchEndpoints() {
try {
const endpoints = await getEndpoints(NETWORK_TYPE.MAINNET, ENDPOINT_TYPE.REST);
console.log("Endpoints:", JSON.stringify(endpoints, null, 2));
} catch (error) {
console.error("Error fetching endpoints:", error);
}
}
fetchEndpoints();
+
+
+Retrieves and sorts endpoints by their health status.
+The network to get endpoints for.
+The type of endpoint to retrieve.
+A promise that resolves to an array of endpoints sorted by response time.
+import { NETWORK_TYPE, ENDPOINT_TYPE, getEndpointsSorted } from "@akashnetwork/akashjs/build/network";
const displaySortedEndpoints = async () => {
try {
const endpoints = await getEndpointsSorted(NETWORK_TYPE.MAINNET, ENDPOINT_TYPE.RPC);
console.log("Sorted Endpoints:", JSON.stringify(endpoints, null, 2));
} catch (error) {
console.error("Error fetching sorted endpoints:", error);
}
};
displaySortedEndpoints();
+
+
+Fetches metadata for a specified network.
+The network identifier for which to fetch metadata.
+A promise that resolves to the network metadata.
+import { NETWORK_TYPE, getMetadata } from "@akashnetwork/akashjs/build/network";
async function displayNetworkMetadata() {
try {
const metadata = await getMetadata(NETWORK_TYPE.MAINNET);
console.log("Network Metadata:", metadata);
} catch (error) {
console.error("Error fetching network metadata:", error);
}
}
displayNetworkMetadata();
+
+
+Creates an Amino message object.
+The type of the message.
+The body of the message.
+The Amino message object.
+Creates a Stargate message object with a fee.
+The Stargate message object with a fee.
+Creates a message client for sending transactions to the Akash network
+The RPC endpoint URL to connect to
+The signer used to sign transactions
+A client for signing and sending transactions
+Retrieves a wallet account by address.
+This function fetches the mnemonic associated with the given address from local storage +and imports the account using that mnemonic.
+The address of the account to retrieve.
+The wallet accounts associated with the given address.
+Connect and communicate with the Akash Network. Pure JS library can be used in browser for unsigned transactions, and with node.js for full compatibility.
+This repository is the home of akashjs
, a library designed to facilitate interaction with the Akash Network. However, for full functionality, users will need to integrate several additional libraries. The Akash Network is built using the Cosmos SDK and utilizes the Stargate client for transaction signing and broadcasting. These packages are specifically tailored to enhance interaction with the Akash Network.
Package | +Description | +
---|---|
@akashnetwork/akashjs | +Main library for interacting with the Akash Network | +
@akashnetwork/akash-api | +Akash API generated from Akash API for interacting with the Akash Network. Documentation is available for node and provider. | +
@cosmjs/stargate | +A client library for the Cosmos SDK 0.40+ (Stargate). | +
@cosmjs/proto-signing | +A library for signing and broadcasting transactions using the Cosmos SDK. | +
Documentation for the library is available here.
+Compatible with modern browsers, nodejs 14+ and Webpack 5
+To install the library, run the following command:
+npm install @akashnetwork/akashjs
+
+
+Or use the UMD bundle (the object returned is Window.akjs
):
<script type="text/javascript" src="https://unpkg.com/@akashnetwork/akashjs@0.10.0/umd/akashjs.js" ></script>
+
+
+The following example demonstrates how to fetch the state of the network.
+import { getMetadata } from "@akashnetwork/akashjs/build/network/index.js";
console.log(JSON.stringify(await getMetadata("mainnet"), null, 2))
+
+
+More elborate examples can be found in the examples directory.
+This repository is primarily written in TypeScript and uses Node.js version 18. We use Webpack 5 for UMD bundling. These tools ensure that our development environment is consistent and our builds are stable.
+Prerequisites
+Installation
+# Clone the repository
git clone https://github.com/akash-network/akashjs
cd akashjs
# Install dependencies
npm install
# Setup git hooks
npm run setup-git-hooks
+
+
+# Watch mode for development
npm run dev:watch
# Run tests
npm run test
# Run linting
npm run lint
# Fix linting issues
npm run lint:fix
# Format code
npm run format
# Build the project
npm run build
+
+
+TypeScript
+any
type where possibleTesting
+npm test
before submitting PRsCode Style
+Our project enforces high standards of code quality and consistency through:
+To enable git hooks for local development:
+npm run setup-git-hooks
+
+
+main
dev:watch
command for live reloading during developmentexamples
directory for implementation references--inspect
flagDEBUG=akashjs:*
environment variable for detailed logsPRs are welcome! By adhering to these guidelines and leveraging our automated systems, we can maintain a high-quality codebase and streamline our development processes.
+Interface representing the PEM-formatted certificate components
+Network metadata interface +INetworkMetadata
+A mapping of API types to their respective endpoint addresses.
+The prefix used for Bech32 encoded addresses on the network.
+A unique identifier for the blockchain network.
+The name of the blockchain network.
+Details about the codebase of the network.
+The name of the daemon process used by the network.
+Information about the genesis block of the network.
+The type of network, indicating whether it's a mainnet, testnet, or edgenet.
+The directory path where the node's data is stored.
+Information about network peers.
+A human-readable name for the network.
+The current operational status of the network (e.g., active, inactive).
+Main exports for the Akash JS
+Certificate module for handling SSL/TLS certificates.
+Network module for network-related operations.
+Protocol client module for protocol buffer client operations.
+RPC module for remote procedure calls.
+SDL module for handling SDL files.
+Stargate module for interacting with the Cosmos SDK.
+Wallet module for managing cryptocurrency wallets.
+Const
Const
Const
Const
Represents an SDL validation error. +Extends the base
+ValidationError
class.