Akash Python SDK
Python SDK for interacting with the Akash blockchain and deploying workloads on the decentralized cloud marketplace.
Installation
pip install akash
Prerequisites
- Python 3.8+
Quick start
Setup
from akash import AkashClient, AkashWallet
wallet = AkashWallet.from_mnemonic("your twelve word mnemonic phrase here")
print(f"Wallet address: {wallet.address}")
client = AkashClient("https://akash-rpc.polkachu.com:443")
print(f"Connected: {client.health_check()}")
Send tokens
from akash import AkashClient, AkashWallet
client = AkashClient("https://akash-rpc.polkachu.com:443")
wallet = AkashWallet.from_mnemonic("your mnemonic here")
result = client.bank.send(
wallet=wallet,
to_address="akash1recipient_address",
amount="1000000",
memo=""
)
if result.success:
print(f"Transfer successful: {result.tx_hash}")
else:
print(f"Transfer failed: {result.raw_log}")
Vote on governance proposal
from akash import AkashClient, AkashWallet
client = AkashClient("https://akash-rpc.polkachu.com:443")
wallet = AkashWallet.from_mnemonic("your mnemonic here")
result = client.governance.vote(
wallet=wallet,
proposal_id=42,
option="YES"
)
if result.success:
print(f"Vote successful: {result.tx_hash}")
else:
print(f"Vote failed: {result.raw_log}")
Deploy application
from akash import AkashClient, AkashWallet
import time
wallet = AkashWallet.from_mnemonic("your mnemonic here")
client = AkashClient("https://akash-rpc.polkachu.com:443")
print("Step 1: Ensuring certificate")
success, cert_pem, key_pem = client.cert.ensure_certificate(wallet)
if not success:
print("Certificate setup failed")
exit()
print("Step 2: Creating deployment from SDL")
sdl = '''
version: "2.0"
services:
web:
image: nginx:latest
expose:
- port: 80
as: 80
to:
- global: true
profiles:
compute:
web:
resources:
cpu:
units: 0.5
memory:
size: 128Mi
storage:
size: 1Gi
placement:
akash:
attributes:
host: akash
pricing:
web:
denom: uakt
amount: 100
deployment:
web:
akash:
profile: web
count: 1
'''
deployment = client.deployment.create_deployment(
sdl_yaml=sdl,
wallet=wallet,
deposit="500000"
)
if not deployment.success:
print(f"Deployment failed: {deployment.raw_log}")
exit()
dseq = deployment.dseq
print(f"Deployment created: DSEQ {dseq}")
print("Step 3: Waiting for bids...")
time.sleep(30)
bids = client.market.get_bids(owner=wallet.address, dseq=dseq)
if not bids:
print("No bids received")
exit()
print("Step 4: Selecting best bid and creating lease")
provider_addresses = [b['bid_id']['provider'] for b in bids]
valid_providers = client.provider.filter_valid_providers(provider_addresses)
if not valid_providers:
print("No valid providers found")
exit()
valid_bids = [b for b in bids if b['bid_id']['provider'] in valid_providers]
best_bid = min(valid_bids, key=lambda b: float(b['price']['amount']))
lease = client.market.create_lease_from_bid(wallet, best_bid)
if not lease['success']:
print(f"Lease failed: {lease['error']}")
exit()
print(f"Lease created with provider: {lease['provider_endpoint']}")
print("Step 5: Submitting manifest")
time.sleep(10)
manifest_result = client.manifest.submit_manifest(
provider_endpoint=lease['provider_endpoint'],
lease_id=lease['lease_id'],
sdl_content=sdl,
cert_pem=cert_pem,
key_pem=key_pem
)
if manifest_result.get('status') == 'success':
print("Manifest submitted successfully")
print("Your nginx application is now running")
else:
print(f"Manifest submission failed: {manifest_result.get('error')}")
Query deployment manifest
from akash import AkashClient, AkashWallet
import time
wallet = AkashWallet.from_mnemonic("your mnemonic here")
client = AkashClient("https://akash-rpc.polkachu.com:443")
success, cert_pem, key_pem = client.cert.ensure_certificate(wallet)
lease_id = {
"dseq": "12345",
"gseq": 1,
"oseq": 1
}
time.sleep(10)
result = client.manifest.get_deployment_manifest(
provider_endpoint="https://provider.example.com:8443",
lease_id=lease_id,
cert_pem=cert_pem,
key_pem=key_pem
)
if result["status"] == "success":
print(f"Provider version: {result['provider_version']}")
for group in result["manifest"]:
for service in group['services']:
print(f"Service: {service['name']}")
print(f"Image: {service['image']}")
resources = service['resources']
cpu = resources['cpu']['units']['val']
mem = int(resources['memory']['size']['val']) / (1024**2)
print(f"CPU: {cpu} millicores, Memory: {mem:.0f}Mi")
else:
print(f"Query failed: {result['error']}")
Provider discovery
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
all_providers = client.provider.get_providers()
gpu_providers = client.provider.get_providers_by_capabilities(["gpu"])
high_perf_providers = client.provider.get_providers_by_capabilities(["high-performance"])
us_providers = client.provider.get_providers_by_region("us-west")
if all_providers:
provider_detail = client.provider.get_provider(all_providers[0]['owner'])
print(f"Provider: {provider_detail['host_uri']}")
print(f"Total: {len(all_providers)}, GPU: {len(gpu_providers)}")
print(f"High performance: {len(high_perf_providers)}, US West: {len(us_providers)}")
Market operations
from akash import AkashClient, AkashWallet
client = AkashClient("https://akash-rpc.polkachu.com:443")
wallet = AkashWallet.from_mnemonic("provider mnemonic here")
bids = client.market.get_bids(state="open", limit=20)
print(f"Found {len(bids)} open bids")
bid = client.market.create_bid(
wallet=wallet,
owner="akash1...",
dseq=123,
gseq=1,
oseq=1,
price="1000"
)
leases = client.market.get_leases(provider=wallet.address)
print(f"Active leases: {len(leases)}")
Core components
AkashClient
Main entry point for the SDK. Manages RPC connections and provides access to all functionality.
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
with AkashClient("https://akash-rpc.polkachu.com:443") as client:
deployments = client.deployment.get_deployments()
AkashWallet
Handles wallet operations, key management, and transaction signing.
from akash import AkashWallet
wallet = AkashWallet.generate()
print(f"New wallet: {wallet.address}")
print(f"Mnemonic: {wallet.mnemonic}")
wallet = AkashWallet.from_mnemonic("your mnemonic phrase")
wallet = AkashWallet.from_private_key("your private key")
signed_tx = wallet.sign_transaction(tx_data)
client = AkashClient("https://akash-rpc.polkachu.com:443")
balance = client.bank.get_balance(wallet.address)
print(f"Balance: {balance} uakt")
Sub-clients
The client provides access to all Akash modules:
- audit: Provider audit operations
- auth: Auth operations
- authz: Authz operations
- bank: Token transfers and balance queries
- cert: Certificate management
- deployment: Deployment lifecycle management
- discovery: Discovery operations
- distribution: Staking rewards distribution
- escrow: Escrow account management
- evidence: Evidence of misbehavior submission
- feegrant: Fee grant operations
- governance: Governance proposals and voting
- ibc: Inter-blockchain communication
- inflation: Inflation parameter queries
- inventory: Inventory management
- manifest: Deployment manifest operations
- market: Bidding and lease operations
- provider: Provider discovery and filtering
- slashing: Validator slashing operations
- staking: Staking operations
Network endpoints
Testnet:
- RPC:
https://rpc.sandbox-01.aksh.pw:443 - Chain ID:
sandbox-01
Mainnet:
- RPC:
https://akash-rpc.polkachu.com:443 - Chain ID:
akashnet-2
Links
Release files for akash 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| akash-0.6.0.tar.gz | 610.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| akash-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.7 MB
Release files / akash-0.6.0.tar.gz
| Download URL | akash-0.6.0.tar.gz |
|---|---|
| Size | 610.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd65802deaad244accf40fb1667cb240efb2f111016e6859001ee62881315f69
|
|
BLAKE2b-256 checksum How to use checksums |
b8b40b209a7c840c798dbdefb50ef78015daff029e3a977a9fbc6ca32241a8d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / akash-0.6.0-py3-none-any.whl
| Download URL | akash-0.6.0-py3-none-any.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3586e38569d32ee4ec120b995e09f42dee4759d5022a33ea49ef378e4c36e224
|
|
BLAKE2b-256 checksum How to use checksums |
801e9344842dc93419d35c39bf8f15b19c9038d982cd71e0b2f9004f59259959
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|