Auth module¶
The auth module provides account querying functionality for authentication and account management on the Akash Network.
AuthClient Class¶
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
auth = client.auth
Queries¶
get_account()¶
Query detailed information for a specific account.
Required parameters:
address
(str
): Bech32 account address to query
Returns: Optional[Dict]
- Account information with the following fields:
@type
(str
): Account typeaddress
(str
): Bech32 account addressaccount_number
(str
): Unique account numbersequence
(str
): Current sequence number for transactionspub_key
(Dict
, optional): Public key information if account has sent transactions, containing:@type
(str
): Public key typekey
(str
): Base64-encoded public key
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
account = client.auth.get_account("akash1ccktptfkvdc67msahlhmnzg5md3wh30u5h7vm4")
if account:
print(f"Account type: {account['@type']}")
print(f"Account number: {account['account_number']}")
print(f"Sequence: {account['sequence']}")
if account.get('pub_key'):
print(f"Public key type: {account['pub_key']['@type']}")
else:
print("No public key (never sent transactions)")
else:
print("Account not found or never been used")
get_accounts()¶
Query all accounts on the network with pagination support.
Optional parameters:
limit
(int
): Maximum number of results to return (default: None)offset
(int
): Number of results to skip (default: None)
Returns: List[Dict]
- List of account information with the following fields:
@type
(str
): Account typeaddress
(str
): Bech32 account addressaccount_number
(str
): Unique account numbersequence
(str
): Current sequence number for transactionspub_key
(Dict
, optional): Public key information if available
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
accounts = client.auth.get_accounts(limit=100)
print(f"Found {len(accounts)} accounts:")
for account in accounts[:5]:
print(f"{account['address']}: seq={account['sequence']}")
get_module_account_by_name()¶
Query a module account by its name.
Required parameters:
name
(str
): Module account name (e.g., "bonded_tokens_pool", "escrow")
Returns: Optional[Dict]
- Module account information with the following fields:
@type
(str
): Account typename
(str
): Module account namepermissions
(List[str]
): List of module permissionsbase_account
(Dict
): Base account information containing:address
(str
): Module account addressaccount_number
(str
): Unique account numbersequence
(str
): Current sequence number
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
bonded_pool = client.auth.get_module_account_by_name("bonded_tokens_pool")
if bonded_pool:
print(f"Module: {bonded_pool['name']}")
print(f"Address: {bonded_pool['base_account']['address']}")
print(f"Permissions: {bonded_pool.get('permissions', [])}")
get_auth_params()¶
Query authentication module parameters.
Returns: Optional[Dict]
- Authentication parameters with the following fields:
max_memo_characters
(str
): Maximum characters allowed in transaction memostx_sig_limit
(str
): Maximum number of signatures per transactiontx_size_cost_per_byte
(str
): Cost per byte for transaction sizesig_verify_cost_ed25519
(str
): Cost to verify ED25519 signaturessig_verify_cost_secp256k1
(str
): Cost to verify SECP256K1 signatures
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
params = client.auth.get_auth_params()
if params:
print(f"Max memo characters: {params.get('max_memo_characters', 'N/A')}")
print(f"TX sig limit: {params.get('tx_sig_limit', 'N/A')}")
print(f"TX size cost per byte: {params.get('tx_size_cost_per_byte', 'N/A')}")
print(f"Sig verify cost ED25519: {params.get('sig_verify_cost_ed25519', 'N/A')}")
Utils¶
get_account_info()¶
Get basic account information with error handling convenience method.
Required parameters:
address
(str
): Bech32 account address
Returns: Optional[Dict]
- Basic account information with the following fields:
address
(str
): Bech32 account addresssequence
(int
): Current sequence numberaccount_number
(int
): Unique account numberhas_pub_key
(bool
): Whether account has public key set
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
info = client.auth.get_account_info("akash1ccktptfkvdc67msahlhmnzg5md3wh30u5h7vm4")
if info:
print(f"Sequence: {info['sequence']}")
print(f"Account number: {info['account_number']}")
print(f"Has public key: {info['has_pub_key']}")
validate_address()¶
Validate if an address is correctly formatted using proper bech32 validation.
Required parameters:
address
(str
): Bech32 address to validate
Returns: bool
- True if address format is valid, False otherwise
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
addresses = [
"akash1ccktptfkvdc67msahlhmnzg5md3wh30u5h7vm4",
"akash1invalidaddress123",
"cosmos1differentchain456"
]
for addr in addresses:
is_valid = client.auth.validate_address(addr)
status = "Valid format" if is_valid else "Invalid format"
print(f"{addr}: {status}")
validate_address_existence()¶
Validate if an address exists on the blockchain (has been used).
Required parameters:
address
(str
): Bech32 address to validate
Returns: bool
- True if address exists on blockchain, False otherwise
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
addresses = [
"akash1ccktptfkvdc67msahlhmnzg5md3wh30u5h7vm4", # existing address
"akash1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq7l2vta" # valid format but never used
]
for addr in addresses:
is_valid_format = client.auth.validate_address(addr)
print(f"{addr}:")
print(f"Format valid: {is_valid_format}")
if is_valid_format:
exists = client.auth.validate_address_existence(addr)
print(f"Exists on chain: {exists}")
get_next_sequence_number()¶
Get the next sequence number for an account for transaction signing.
Required parameters:
address
(str
): Bech32 account address
Returns: int
- Next sequence number for transactions
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
next_seq = client.auth.get_next_sequence_number("akash1ccktptfkvdc67msahlhmnzg5md3wh30u5h7vm4")
print(f"Next sequence number: {next_seq}")
get_account_number()¶
Get the account number for an account.
Required parameters:
address
(str
): Bech32 account address
Returns: int
- Account number (needed for transaction signing)
Example: