Skip to content

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.

def get_account(address: str) -> Optional[Dict]

Required parameters:

  • address (str): Bech32 account address to query

Returns: Optional[Dict] - Account information with the following fields:

  • @type (str): Account type
  • address (str): Bech32 account address
  • account_number (str): Unique account number
  • sequence (str): Current sequence number for transactions
  • pub_key (Dict, optional): Public key information if account has sent transactions, containing:
    • @type (str): Public key type
    • key (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.

def get_accounts(limit: Optional[int] = None, offset: Optional[int] = None) -> List[Dict]

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 type
  • address (str): Bech32 account address
  • account_number (str): Unique account number
  • sequence (str): Current sequence number for transactions
  • pub_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.

def get_module_account_by_name(name: str) -> Optional[Dict]

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 type
  • name (str): Module account name
  • permissions (List[str]): List of module permissions
  • base_account (Dict): Base account information containing:
    • address (str): Module account address
    • account_number (str): Unique account number
    • sequence (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.

def get_auth_params() -> Optional[Dict]

Returns: Optional[Dict] - Authentication parameters with the following fields:

  • max_memo_characters (str): Maximum characters allowed in transaction memos
  • tx_sig_limit (str): Maximum number of signatures per transaction
  • tx_size_cost_per_byte (str): Cost per byte for transaction size
  • sig_verify_cost_ed25519 (str): Cost to verify ED25519 signatures
  • sig_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.

def get_account_info(address: str) -> Optional[Dict]

Required parameters:

  • address (str): Bech32 account address

Returns: Optional[Dict] - Basic account information with the following fields:

  • address (str): Bech32 account address
  • sequence (int): Current sequence number
  • account_number (int): Unique account number
  • has_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.

def validate_address(address: str) -> bool

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).

def validate_address_existence(address: str) -> bool

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.

def get_next_sequence_number(address: str) -> int

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.

def get_account_number(address: str) -> int

Required parameters:

  • address (str): Bech32 account address

Returns: int - Account number (needed for transaction signing)

Example:

from akash import AkashClient

client = AkashClient("https://akash-rpc.polkachu.com:443")

acc_num = client.auth.get_account_number("akash1ccktptfkvdc67msahlhmnzg5md3wh30u5h7vm4")
print(f"Account number: {acc_num}")