Akash SDK - API Reference

Complete API reference for the Akash SDKs.

Both SDKs are generated from the same protobuf definitions and follow similar patterns.


SDK Initialization

import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { createChainNodeSDK } from "@akashnetwork/chain-sdk";

// Initialize wallet from mnemonic
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { 
  prefix: "akash" 
});

// Initialize SDK
const sdk = createChainNodeSDK({
  query: {
    baseUrl: "https://grpc.akashnet.net:443", // gRPC endpoint
    transportOptions: {
      pingIntervalMs: 30000,
      pingTimeoutMs: 10000,
      idleConnectionTimeoutMs: 60000,
      defaultTimeoutMs: 30000
    }
  },
  tx: {
    baseUrl: "https://rpc.akashnet.net:443", // RPC endpoint
    signer: wallet,
    gasPrice: "0.025uakt"
  }
});

// SDK exposes:
// - sdk.akash.* (Akash-specific modules)
// - sdk.cosmos.* (Cosmos SDK modules)

TypeScript Options:

  • query.baseUrl (required): gRPC endpoint URL
  • query.transportOptions (optional): Connection settings
  • tx.baseUrl (required for transactions): RPC endpoint URL
  • tx.signer (required for transactions): CosmJS wallet instance
  • tx.gasPrice (optional): Gas price (default: “0.025uakt”)

SDL Operations

import { SDL } from "@akashnetwork/chain-sdk";

// Parse SDL from YAML string
const sdl = SDL.fromString(yamlString, "beta3", "mainnet");

// Get deployment manifest
const manifest = sdl.manifest();
// Returns: Array of deployment groups with service definitions

// Get deployment groups
const groups = sdl.groups();
// Returns: Array of GroupSpec objects for blockchain submission

TypeScript Methods:

  • SDL.fromString(yaml, version?, networkId?) - Parse SDL from YAML
    • yaml: YAML string
    • version: “beta2” | “beta3” (default: “beta3”)
    • networkId: “mainnet” | “testnet” | “sandbox” (default: “mainnet”)
  • sdl.manifest() - Get deployment manifest
  • sdl.groups() - Get deployment groups for blockchain

Go Functions:

  • sdl.ReadFile(path) - Read SDL from file
  • sdl.Read([]byte) - Parse SDL from bytes
  • DeploymentGroups() - Get deployment groups
  • Manifest() - Get deployment manifest
  • Version() - Get SDL version hash

Deployment Operations

Query Deployments

// Get all deployments for owner
const result = await sdk.akash.deployment.v1beta4.getDeployments({
  filters: {
    owner: "akash1...",
    state: "active" // "active" | "closed" | undefined
  },
  pagination: {
    limit: 100,
    offset: 0
  }
});

// result.deployments: Array of deployment info
// result.pagination: Pagination info

// Get specific deployment
const deployment = await sdk.akash.deployment.v1beta4.getDeployment({
  id: {
    owner: "akash1...",
    dseq: "1234567"
  }
});

Create Deployment

import { SDL } from "@akashnetwork/chain-sdk";

const sdl = SDL.fromString(yamlString);
const groups = sdl.groups();

// Get current block height for dseq
const status = await sdk.cosmos.base.tendermint.v1beta1.getLatestBlock({});
const dseq = status.block.header.height;

// Get account
const accounts = await wallet.getAccounts();

// Create deployment
const result = await sdk.akash.deployment.v1beta4.createDeployment({
  id: {
    owner: accounts[0].address,
    dseq: dseq
  },
  groups: groups,
  deposit: {
    denom: "uakt",
    amount: "5000000" // 5 AKT
  },
  depositor: accounts[0].address
});

// Returns transaction result

Update Deployment

const sdl = SDL.fromString(newYamlString);
const groups = sdl.groups();

const result = await sdk.akash.deployment.v1beta4.updateDeployment({
  id: {
    owner: accounts[0].address,
    dseq: "1234567"
  },
  groups: groups
});

Close Deployment

const result = await sdk.akash.deployment.v1beta4.closeDeployment({
  id: {
    owner: accounts[0].address,
    dseq: "1234567"
  }
});

Market Operations

Query Bids

const bids = await sdk.akash.market.v1beta5.getBids({
  filters: {
    owner: "akash1...",
    dseq: "1234567",
    state: "open" // "open" | "active" | "closed"
  },
  pagination: {
    limit: 100
  }
});

// bids.bids: Array of bid info

Create Lease (Accept Bid)

const result = await sdk.akash.market.v1beta5.createLease({
  bidId: {
    owner: accounts[0].address,
    dseq: "1234567",
    gseq: 1,
    oseq: 1,
    provider: "akash1..."
  }
});

Query Leases

const leases = await sdk.akash.market.v1beta5.getLeases({
  filters: {
    owner: "akash1...",
    state: "active"
  },
  pagination: {
    limit: 100
  }
});

Provider Operations

Query Providers

// Get all providers
const providers = await sdk.akash.provider.v1beta4.getProviders({
  pagination: {
    limit: 100
  }
});

// Get specific provider
const provider = await sdk.akash.provider.v1beta4.getProvider({
  owner: "akash1..."
});

Provider Status (Provider API)

import { createProviderSDK } from "@akashnetwork/chain-sdk";

const providerSdk = createProviderSDK({
  baseUrl: "https://provider.example.com:8444"
});

// Get provider status
const status = await providerSdk.akash.provider.v1.getStatus();

// status.clusterPublicHostname: string
// status.availableResources: Resource info
// status.pendingResources: Resource info
// status.leasedResources: Resource info

Certificate Operations

Query Certificates

const certs = await sdk.akash.cert.v1.getCertificates({
  filter: {
    owner: "akash1...",
    state: "valid"
  },
  pagination: {
    limit: 100
  }
});

Create Certificate

import { certificateManager } from "@akashnetwork/chain-sdk";

const accounts = await wallet.getAccounts();

// Generate certificate pair
const certPair = await certificateManager.generatePEM(accounts[0].address);

// Publish to blockchain
const result = await sdk.akash.cert.v1.createCertificate({
  owner: accounts[0].address,
  cert: Buffer.from(certPair.cert, 'utf-8'),
  pubkey: Buffer.from(certPair.publicKey, 'utf-8')
});

// Save certPair.cert and certPair.privateKey for later use

Revoke Certificate

const result = await sdk.akash.cert.v1.revokeCertificate({
  id: {
    owner: accounts[0].address,
    serial: "certificate-serial-number"
  }
});

Cosmos SDK Operations

Query Account Balance

// Get balance for specific denom
const balance = await sdk.cosmos.bank.v1beta1.getBalance({
  address: "akash1...",
  denom: "uakt"
});

// balance.balance.amount: string (in uakt)
// Convert to AKT: parseInt(balance.balance.amount) / 1000000

// Get all balances
const allBalances = await sdk.cosmos.bank.v1beta1.getAllBalances({
  address: "akash1...",
  pagination: {
    limit: 100
  }
});

Send Tokens

const result = await sdk.cosmos.bank.v1beta1.send({
  fromAddress: accounts[0].address,
  toAddress: "akash1...",
  amount: [{
    denom: "uakt",
    amount: "1000000" // 1 AKT
  }]
});

Query Block Info

// Get latest block
const latest = await sdk.cosmos.base.tendermint.v1beta1.getLatestBlock({});

// latest.block.header.height: string
// latest.block.header.time: timestamp

// Get block by height
const block = await sdk.cosmos.base.tendermint.v1beta1.getBlockByHeight({
  height: "1234567"
});

Authentication

JWT Token

import { Secp256k1HdWallet } from "@cosmjs/amino";
import { JwtTokenManager } from "@akashnetwork/chain-sdk";

const wallet = await Secp256k1HdWallet.fromMnemonic(mnemonic, { 
  prefix: "akash" 
});
const accounts = await wallet.getAccounts();

// Initialize token manager
const tokenManager = new JwtTokenManager(wallet);

// Generate JWT token
const token = await tokenManager.generateToken({
  iss: accounts[0].address,
  exp: Math.floor(Date.now() / 1000) + 3600, // 1 hour
  iat: Math.floor(Date.now() / 1000),
  version: "v1",
  leases: { access: "full" }
});

// Use token for provider API requests
const response = await fetch(
  `https://provider.example.com:8443/lease/${dseq}/1/1/status`,
  {
    headers: {
      Authorization: `Bearer ${token}`
    }
  }
);

JWT Token Claims:

  • iss (required): Issuer address (your Akash address)
  • exp (required): Expiration timestamp (Unix time)
  • iat (required): Issued at timestamp (Unix time)
  • nbf (required): Not before timestamp (Unix time)
  • version (required): Token version (“v1”)
  • leases (required): Lease access permissions

Access Types:

  • full - Full access to all leases (TypeScript: { access: "full" }, Go: AccessTypeFull)
  • scoped - Scoped access with specific permissions (Go: AccessTypeScoped)
  • granular - Granular access per deployment (Go: AccessTypeGranular)

Error Handling

import { TxError } from "@akashnetwork/chain-sdk";

try {
  const result = await sdk.akash.deployment.v1beta4.createDeployment({...});
} catch (error) {
  if (error instanceof TxError) {
    console.error("Transaction failed:", error.message);
    console.error("Code:", error.code);
    console.error("Codespace:", error.codespace);
  } else {
    console.error("Unknown error:", error);
  }
}

Type Definitions

// Deployment ID
interface DeploymentID {
  owner: string;
  dseq: string;
}

// Bid ID
interface BidID {
  owner: string;
  dseq: string;
  gseq: number;
  oseq: number;
  provider: string;
}

// Coin
interface Coin {
  denom: string;
  amount: string;
}

// Pagination
interface PageRequest {
  key?: Uint8Array;
  offset?: number;
  limit?: number;
  countTotal?: boolean;
  reverse?: boolean;
}

footer-logo-dark

© Akash Network 2025 The Akash Network Authors Documentation Distributed under CC BY 4.0

Open-source Apache 2.0 Licensed.

GitHub v0.38.2

Privacy