Client module¶
The AkashClient
is the main entry point for interacting with Akash Network using RPC endpoints. It provides access to all blockchain modules and convenience methods for common operations.
Class definition¶
class AkashClient:
def __init__(
self,
rpc_endpoint: str = "https://akash-rpc.polkachu.com:443",
chain_id: str = "akashnet-2"
)
Constructor parameters¶
Parameter | Type | Default | Description |
---|---|---|---|
rpc_endpoint |
str |
"https://akash-rpc.polkachu.com:443" |
RPC server endpoint URL |
chain_id |
str |
"akashnet-2" |
Blockchain chain ID for transactions |
Properties¶
rpc_endpoint¶
The RPC endpoint this client is connected to.
Returns: str
- The RPC endpoint URL
chain_id¶
The blockchain chain ID this client is configured for.
Returns: str
- The chain ID
Module clients¶
The AkashClient
provides access to specialized module clients for different blockchain operations:
Audit¶
Audit operations
Auth¶
Auth operations
Authz¶
Authz operations
Bank¶
Banking operations
Cert¶
Certificate operations
Deployment¶
Deployment operations
Discovery¶
Discovery operations
Distribution¶
Distribution operations (rewards and commission)
Escrow¶
Escrow operations
Evidence¶
Evidence operations
Feegrant¶
Fee grant operations
Governance¶
Governance operations (proposals, voting)
IBC¶
IBC operations
Inflation¶
Inflation operations
Inventory¶
Inventory management operations
Manifest¶
Manifest management operations
Market¶
Marketplace operations (orders, bids, leases)
Provider¶
Provider operations
Slashing¶
Slashing operations
Staking¶
Staking operations (delegation, validators, rewards)
Core methods¶
rpc_query()¶
Perform an RPC query.
Parameters:
method
(str
): RPC method nameparams
(List[Any]
): RPC parameters
Returns: Dict[str, Any]
- RPC response with the following fields:
jsonrpc
(str
): JSON-RPC versionid
(int
): Request IDresult
(Any
): Method-specific result dataerror
(Dict
, optional): Error information if request failedcode
(int
): Error codemessage
(str
): Error message
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
result = client.rpc_query("status")
print(f"Latest block: {result['sync_info']['latest_block_height']}")
abci_query()¶
Perform an ABCI query via RPC.
Parameters:
path
(str
): Query pathdata
(str
): Query data (hex encoded)prove
(bool
): Include proof in response
Returns: Dict[str, Any]
- ABCI query response with the following fields:
response
(Dict
): ABCI responsecode
(int
): Response code (0 for success)log
(str
): Response loginfo
(str
): Additional infoindex
(str
): Response indexkey
(str
): Query key (base64)value
(str
): Query value (base64)proof_ops
(Dict
, optional): Proof operations if requestedheight
(str
): Block heightcodespace
(str
): Code namespace
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
result = client.abci_query("/cosmos.staking.v1beta1.Query/Validators")
print(f"Query response code: {result['response']['code']}")
broadcast_tx_async()¶
Broadcast transaction using broadcast_tx_async.
⚠️ Getting code 0 and a transaction hash does NOT guarantee the transaction succeeded. The transaction is only queued for mempool inclusion. Use broadcast_tx_sync()
or wait for blockchain confirmation to verify actual success.
Parameters:
tx_bytes
(bytes
): Serialized transaction bytes
Returns: Dict[str, Any]
- Broadcast result with the following fields:
jsonrpc
(str
): JSON-RPC versionid
(int
): Request IDresult
(Dict
): Broadcast resultcode
(int
): Response code (0 for success)data
(str
): Response datalog
(str
): Transaction loghash
(str
): Transaction hash
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
result = client.broadcast_tx_async(tx_bytes)
print(f"Transaction hash: {result.get('hash')}")
broadcast_tx_sync()¶
Broadcast transaction using broadcast_tx_sync.
Parameters:
tx_bytes
(bytes
): Serialized transaction bytes
Returns: Dict[str, Any]
- Broadcast result with the following fields:
jsonrpc
(str
): JSON-RPC versionid
(int
): Request IDresult
(Dict
): Broadcast resultcode
(int
): Response code (0 for success)data
(str
): Response datalog
(str
): Transaction loghash
(str
): Transaction hash
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
result = client.broadcast_tx_sync(tx_bytes)
print(f"Transaction hash: {result.get('hash')}")
health_check()¶
Check if the RPC endpoint is healthy.
Parameters:
timeout
(float
): Timeout in seconds
Returns: bool
- True if healthy, False otherwise
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
if client.health_check():
print("RPC endpoint is healthy")
else:
print("RPC endpoint is not responding")
get_network_status()¶
Get network status information.
Returns: Dict[str, Any]
- Network status with the following fields:
network
(str
): Network/chain IDlatest_block_height
(str
): Latest block heightlatest_block_time
(str
): Latest block timestamplatest_block_hash
(str
): Latest block hashearliest_block_height
(str
): Earliest available block heightearliest_block_time
(str
): Earliest block timestampcatching_up
(bool
): Whether node is catching upnode_info
(Dict
): Node informationprotocol_version
(Dict
): Protocol versionsp2p
(str
): P2P protocol versionblock
(str
): Block protocol versionapp
(str
): Application protocol version
id
(str
): Node IDlisten_addr
(str
): Node listen addressnetwork
(str
): Network nameversion
(str
): Node versionchannels
(str
): Supported channelsmoniker
(str
): Node monikerother
(Dict
): Other node infotx_index
(str
): Transaction indexing moderpc_address
(str
): RPC server address
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
status = client.get_network_status()
print(f"Network: {status['network']}")
print(f"Block height: {status['latest_block_height']}")
Convenience methods¶
get_balance()¶
Get account balance - delegates to BankClient.
Parameters:
address
(str
): Account addressdenom
(str
): Token denomination
Returns: str
- Balance amount
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
balance = client.get_balance("akash1qnnhhgzxj24f2kld5yhy4v4h4s9r295ak5gjw4")
print(f"Balance: {int(balance) / 1_000_000:.6f} AKT")
get_balances()¶
Get all balances for an address - delegates to BankClient.
Parameters:
address
(str
): Account address
Returns: Dict[str, str]
- Dictionary of balances by denomination with:
key
(str
): Token denomination (e.g., "uakt", "usdc")value
(str
): Balance amount as string
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
balances = client.get_balances("akash1qnnhhgzxj24f2kld5yhy4v4h4s9r295ak5gjw4")
for denom, amount in balances.items():
print(f"{denom}: {amount}")
get_validators()¶
Get validators list.
Returns: List[Dict[str, Any]]
- List of validator dictionaries with the following fields:
operator_address
(str
): Validator operator addressconsensus_pubkey
(Dict
): Consensus public key@type
(str
): Key type URLkey
(str
): Base64-encoded public key
jailed
(bool
): Whether validator is jailedstatus
(int
): Validator statustokens
(str
): Bonded tokensdelegator_shares
(str
): Delegator sharesdescription
(Dict
): Validator descriptionmoniker
(str
): Validator monikeridentity
(str
): Identity signaturewebsite
(str
): Website URLsecurity_contact
(str
): Security contactdetails
(str
): Description details
unbonding_height
(str
): Unbonding heightunbonding_time
(str
): Unbonding timecommission
(Dict
): Commission informationcommission_rates
(Dict
): Commission ratesrate
(str
): Current commission ratemax_rate
(str
): Maximum commission ratemax_change_rate
(str
): Maximum commission change rate
update_time
(str
): Last commission update time
min_self_delegation
(str
): Minimum self delegation
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
validators = client.get_validators()
print(f"Found {len(validators)} active validators")
get_proposals()¶
Get governance proposals.
Returns: List[Dict[str, Any]]
- List of proposal dictionaries with the following fields:
proposal_id
(str
): Proposal IDcontent
(Dict
): Proposal content@type
(str
): Proposal typetitle
(str
): Proposal titledescription
(str
): Proposal description
status
(int
): Proposal statusfinal_tally_result
(Dict
): Final vote tallyyes
(str
): Yes votesabstain
(str
): Abstain votesno
(str
): No votesno_with_veto
(str
): No with veto votes
submit_time
(str
): Submission timestampdeposit_end_time
(str
): Deposit period end timetotal_deposit
(List[Dict]
): Total depositdenom
(str
): Token denominationamount
(str
): Deposit amount
voting_start_time
(str
): Voting start timevoting_end_time
(str
): Voting end time
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
proposals = client.get_proposals()
print(f"Found {len(proposals)} governance proposals")
get_staking_params()¶
Get staking module parameters.
Returns: Dict[str, Any]
- Staking parameters with the following fields:
unbonding_time
(str
): Unbonding period durationmax_validators
(int
): Maximum number of validatorsmax_entries
(int
): Maximum unbonding/redelegation entrieshistorical_entries
(int
): Number of historical entriesbond_denom
(str
): Bonding token denominationmin_commission_rate
(str
): Minimum commission rate
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
params = client.get_staking_params()
print(f"Unbonding time: {params.get('unbonding_time', 'N/A')}")
get_governance_params()¶
Get governance module parameters.
Returns: Dict[str, Any]
- Governance parameters with the following fields:
voting_params
(Dict
): Voting parametersvoting_period
(str
): Voting period duration
deposit_params
(Dict
): Deposit parametersmin_deposit
(List[Dict]
): Minimum depositdenom
(str
): Token denominationamount
(str
): Minimum amount
max_deposit_period
(str
): Maximum deposit period
tally_params
(Dict
): Tally parametersquorum
(str
): Quorum thresholdthreshold
(str
): Pass thresholdveto_threshold
(str
): Veto threshold
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
params = client.get_governance_params()
print(f"Voting period: {params.get('voting_period', 'N/A')}")
get_account_info()¶
Get account information - delegates to AuthClient.
Parameters:
address
(str
): Account address
Returns: Dict[str, Any]
- Account information with the following fields:
@type
(str
): Account typeaddress
(str
): Account addresspub_key
(Dict
, optional): Public key information@type
(str
): Public key typekey
(str
): Public key (base64)
account_number
(str
): Account numbersequence
(str
): Account sequence number
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
info = client.get_account_info("akash1qnnhhgzxj24f2kld5yhy4v4h4s9r295ak5gjw4")
print(f"Account number: {info.get('account_number', 0)}")
print(f"Sequence: {info.get('sequence', 0)}")
get_delegations()¶
Get delegations for an address.
Parameters:
delegator_address
(str
): Delegator address
Returns: List[Dict[str, Any]]
- List of delegation dictionaries with the following fields:
delegation
(Dict
): Delegation informationdelegator_address
(str
): Delegator addressvalidator_address
(str
): Validator addressshares
(str
): Delegation shares
balance
(Dict
): Delegation balancedenom
(str
): Token denominationamount
(str
): Delegated amount
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
delegations = client.get_delegations("akash1qnnhhgzxj24f2kld5yhy4v4h4s9r295ak5gjw4")
print(f"Active delegations: {len(delegations)}")
get_provider_endpoint()¶
Fetch provider's gRPC endpoint from on-chain data.
Parameters:
provider_address
(str
): Provider's Akash address
Returns: str
- Provider's gRPC endpoint
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
endpoint = client.get_provider_endpoint("akash1365yvmc4s7awdyj3n2sav7xfx76adc6dnmlx63")
print(f"Provider endpoint: {endpoint}")
Context manager support¶
The AkashClient
supports context manager usage for automatic resource cleanup:
from akash import AkashClient
with AkashClient("https://akash-rpc.polkachu.com:443") as client:
balance = client.bank.get_balance("akash1...")
validators = client.staking.get_validators()
Usage examples¶
Basic setup¶
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
client = AkashClient(
rpc_endpoint="https://rpc.sandbox-01.aksh.pw:443",
chain_id="sandbox-01"
)
Health check¶
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
if client.health_check():
print("RPC endpoint is healthy")
status = client.get_network_status()
print(f"Network: {status.get('network', '')}")
print(f"Latest block: {status.get('latest_block_height', '0')}")
else:
print("RPC endpoint not responding")
Account operations¶
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
address = "akash1qnnhhgzxj24f2kld5yhy4v4h4s9r295ak5gjw4"
account_info = client.get_account_info(address)
print(f"Account number: {account_info.get('account_number', 0)}")
print(f"Sequence: {account_info.get('sequence', 0)}")
balance = client.get_balance(address)
print(f"AKT balance: {int(balance) / 1_000_000:.6f}")
balances = client.get_balances(address)
for denom, amount in balances.items():
print(f"{denom}: {amount}")
Network information¶
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
validators = client.get_validators()
print(f"Active validators: {len(validators)}")
staking_params = client.get_staking_params()
print(f"Unbonding time: {staking_params.get('unbonding_time', 'N/A')}")
proposals = client.get_proposals()
print(f"Active proposals: {len(proposals)}")
gov_params = client.get_governance_params()
print(f"Voting period: {gov_params.get('voting_period', 'N/A')}")
Provider operations¶
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
provider_address = "akash1365yvmc4s7awdyj3n2sav7xfx76adc6dnmlx63"
try:
endpoint = client.get_provider_endpoint(provider_address)
print(f"Provider endpoint: {endpoint}")
except Exception as e:
print(f"Failed to get provider endpoint: {e}")