Governance module¶
The governance module provides governance functionality for the Akash Network, enabling democratic participation through proposal creation, voting, and deposits.
Transaction parameters
All transaction functions support flexible parameters. See Transaction parameters for details on available options like fee_amount
, gas_limit
, and gas_adjustment
.
GovernanceClient Class¶
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
governance = client.governance
Transactions¶
submit_text_proposal()¶
Submits a text proposal for governance voting.
def submit_text_proposal(wallet, title: str, description: str,
deposit: str = "10000000", denom: str = "uakt",
memo: str = "", fee_amount: str = None,
gas_limit: int = None, gas_adjustment: float = 1.2,
use_simulation: bool = True) -> BroadcastResult
Required parameters:
wallet
(Wallet
): Wallet to sign the transaction (proposer)title
(str
): Proposal titledescription
(str
): Proposal description
Optional parameters:
deposit
(str
): Initial deposit in base units (default: "10000000")denom
(str
): Token denomination (default: "uakt")memo
(str
): Transaction memo (default: "")fee_amount
(str
): Fee amount in base units (default: None)gas_limit
(int
): Gas limit override (default: None)gas_adjustment
(float
): Multiplier for gas estimation (default: 1.2)use_simulation
(bool
): Enable gas simulation (default: True)
Returns: BroadcastResult
- Transaction result with the following fields:
tx_hash
(str
): Transaction hashcode
(int
): Response code (0 for success)raw_log
(str
): Raw transaction log/error messagesuccess
(bool
): Whether transaction succeededevents
(List[Dict]
): Transaction eventstype
(str
): Event typeattributes
(List[Dict]
): Event attributeskey
(str
): Attribute keyvalue
(str
): Attribute value
Example:
from akash import AkashClient, AkashWallet
client = AkashClient("https://akash-rpc.polkachu.com:443")
wallet = AkashWallet.from_mnemonic("your mnemonic phrase here")
# Submit text proposal
result = client.governance.submit_text_proposal(
wallet=wallet,
title="Akash Network Infrastructure Enhancement",
description="Proposal to enhance the Akash Network infrastructure and improve decentralized compute capabilities.",
deposit="64000000",
denom="uakt"
)
print(f"TX hash: {result.tx_hash}")
print(f"Success: {result.success}")
submit_parameter_change_proposal()¶
Submits a parameter change proposal for governance voting.
def submit_parameter_change_proposal(wallet, title: str, description: str,
changes: List[Dict[str, Any]],
deposit: str = "64000000", denom: str = "uakt",
memo: str = "",
fee_amount: str = None, gas_limit: int = None,
gas_adjustment: float = 1.2, use_simulation: bool = True) -> BroadcastResult
Required parameters:
wallet
(Wallet
): Wallet to sign the transaction (proposer)title
(str
): Proposal titledescription
(str
): Proposal descriptionchanges
(List[Dict]
): List of parameter changes with:subspace
(str
): Parameter subspacekey
(str
): Parameter keyvalue
(str
): New parameter value
Optional parameters:
deposit
(str
): Initial deposit in base units (default: "64000000")denom
(str
): Token denomination (default: "uakt")memo
(str
): Transaction memo (default: "")fee_amount
(str
): Fee amount in base units (default: None)gas_limit
(int
): Gas limit override (default: None)gas_adjustment
(float
): Multiplier for gas estimation (default: 1.2)use_simulation
(bool
): Enable gas simulation (default: True)
Returns: BroadcastResult
- Transaction result with the following fields:
tx_hash
(str
): Transaction hashcode
(int
): Response code (0 for success)raw_log
(str
): Raw transaction log/error messagesuccess
(bool
): Whether transaction succeededevents
(List[Dict]
): Transaction eventstype
(str
): Event typeattributes
(List[Dict]
): Event attributeskey
(str
): Attribute keyvalue
(str
): Attribute value
Example:
from akash import AkashClient, AkashWallet
client = AkashClient("https://akash-rpc.polkachu.com:443")
wallet = AkashWallet.from_mnemonic("your mnemonic phrase here")
changes = [{
"subspace": "staking",
"key": "MaxValidators",
"value": "150"
}]
result = client.governance.submit_parameter_change_proposal(
wallet=wallet,
title="Increase Maximum Validators",
description="Proposal to increase the maximum number of validators from 100 to 150.",
changes=changes
)
print(f"TX hash: {result.tx_hash}")
print(f"Success: {result.success}")
submit_software_upgrade_proposal()¶
Submits a software upgrade proposal for governance voting.
def submit_software_upgrade_proposal(wallet, title: str, description: str,
upgrade_name: str, upgrade_height: int,
upgrade_info: str = "", deposit: str = "64000000", denom: str = "uakt",
memo: str = "", fee_amount: str = None,
gas_limit: int = None, gas_adjustment: float = 1.2,
use_simulation: bool = True) -> BroadcastResult
Required parameters:
wallet
(Wallet
): Wallet to sign the transaction (proposer)title
(str
): Proposal titledescription
(str
): Proposal descriptionupgrade_name
(str
): Name of the software upgradeupgrade_height
(int
): Block height at which to perform upgrade
Optional parameters:
upgrade_info
(str
): Additional upgrade information (default: "")deposit
(str
): Initial deposit in base units (default: "64000000")denom
(str
): Token denomination (default: "uakt")memo
(str
): Transaction memo (default: "")fee_amount
(str
): Fee amount in base units (default: None)gas_limit
(int
): Gas limit override (default: None)gas_adjustment
(float
): Multiplier for gas estimation (default: 1.2)use_simulation
(bool
): Enable gas simulation (default: True)
Returns: BroadcastResult
- Transaction result with the following fields:
tx_hash
(str
): Transaction hashcode
(int
): Response code (0 for success)raw_log
(str
): Raw transaction log/error messagesuccess
(bool
): Whether transaction succeededevents
(List[Dict]
): Transaction eventstype
(str
): Event typeattributes
(List[Dict]
): Event attributeskey
(str
): Attribute keyvalue
(str
): Attribute value
Example:
from akash import AkashClient, AkashWallet
client = AkashClient("https://akash-rpc.polkachu.com:443")
wallet = AkashWallet.from_mnemonic("your mnemonic phrase here")
# Submit software upgrade proposal
result = client.governance.submit_software_upgrade_proposal(
wallet=wallet,
title="Akash Network v0.25.0 Upgrade",
description="Upgrade to Akash Network v0.25.0 with improved performance and new features.",
upgrade_name="v0.25.0",
upgrade_height=12500000,
upgrade_info="Binary available at https://github.com/akash-network/node/releases/tag/v0.25.0"
)
print(f"TX hash: {result.tx_hash}")
print(f"Success: {result.success}")
vote()¶
Votes on a governance proposal.
def vote(wallet, proposal_id: int, option: str,
memo: str = "", fee_amount: str = None,
gas_limit: int = None, gas_adjustment: float = 1.2,
use_simulation: bool = True) -> BroadcastResult
Required parameters:
wallet
(Wallet
): Wallet to sign the transaction (voter)proposal_id
(int
): Proposal ID to vote onoption
(str
): Vote option (YES, NO, ABSTAIN, NO_WITH_VETO)
Optional parameters:
memo
(str
): Transaction memo (default: "")fee_amount
(str
): Fee amount in base units (default: None)gas_limit
(int
): Gas limit override (default: None)gas_adjustment
(float
): Multiplier for gas estimation (default: 1.2)use_simulation
(bool
): Enable gas simulation (default: True)
Returns: BroadcastResult
- Transaction result with the following fields:
tx_hash
(str
): Transaction hashcode
(int
): Response code (0 for success)raw_log
(str
): Raw transaction log/error messagesuccess
(bool
): Whether transaction succeededevents
(List[Dict]
): Transaction eventstype
(str
): Event typeattributes
(List[Dict]
): Event attributeskey
(str
): Attribute keyvalue
(str
): Attribute value
Note: Vote options are case-insensitive and validated against valid options (YES, NO, ABSTAIN, NO_WITH_VETO).
Example:
from akash import AkashClient, AkashWallet
client = AkashClient("https://akash-rpc.polkachu.com:443")
wallet = AkashWallet.from_mnemonic("your mnemonic phrase here")
# Vote on proposal
result = client.governance.vote(
wallet=wallet,
proposal_id=42,
option="YES"
)
print(f"TX hash: {result.tx_hash}")
print(f"Vote successful: {result.success}")
deposit()¶
Deposits tokens to a governance proposal to help it reach the minimum deposit threshold.
def deposit(wallet, proposal_id: int, amount: str = "10000000",
denom: str = "uakt", memo: str = "",
fee_amount: str = None, gas_limit: int = None,
gas_adjustment: float = 1.2, use_simulation: bool = True) -> BroadcastResult
Required parameters:
wallet
(Wallet
): Wallet to sign the transaction (depositor)proposal_id
(int
): Proposal ID to deposit to
Optional parameters:
amount
(str
): Deposit amount in base units (default: "10000000")denom
(str
): Token denomination (default: "uakt")memo
(str
): Transaction memo (default: "")fee_amount
(str
): Fee amount in base units (default: None)gas_limit
(int
): Gas limit override (default: None)gas_adjustment
(float
): Multiplier for gas estimation (default: 1.2)use_simulation
(bool
): Enable gas simulation (default: True)
Returns: BroadcastResult
- Transaction result with the following fields:
tx_hash
(str
): Transaction hashcode
(int
): Response code (0 for success)raw_log
(str
): Raw transaction log/error messagesuccess
(bool
): Whether transaction succeededevents
(List[Dict]
): Transaction eventstype
(str
): Event typeattributes
(List[Dict]
): Event attributeskey
(str
): Attribute keyvalue
(str
): Attribute value
Example:
from akash import AkashClient, AkashWallet
client = AkashClient("https://akash-rpc.polkachu.com:443")
wallet = AkashWallet.from_mnemonic("your mnemonic phrase here")
# Deposit to proposal
result = client.governance.deposit(
wallet=wallet,
proposal_id=42,
amount="10000000",
denom="uakt"
)
print(f"TX hash: {result.tx_hash}")
print(f"Deposit successful: {result.success}")
Queries¶
get_proposals()¶
Retrieves governance proposals from the network.
def get_proposals(status: Optional[str] = None, limit: int = 100, offset: int = 0, count_total: bool = False) -> List[Dict[str, Any]]
Optional parameters:
status
(str
): Filter by proposal status (default: None)limit
(int
): Maximum number of results to return (default: 100)offset
(int
): Number of results to skip (default: 0)count_total
(bool
): Include total count in response (default: False)
Returns: List[Dict]
- List of proposals, each containing:
proposal_id
(int
): Unique proposal identifiercontent
(Dict
): Proposal content with title, description, and typetitle
(str
): Proposal titlestatus
(int
): Proposal status codefinal_tally_result
(Dict
): Vote tally with yes, no, abstain, no_with_veto countssubmit_time
(str
): Timestamp when proposal was submitteddeposit_end_time
(str
): Timestamp when deposit period endstotal_deposit
(List[Dict]
): List of deposited coinsdenom
(str
): Token denominationamount
(str
): Deposit amount
voting_start_time
(str
): Timestamp when voting period startsvoting_end_time
(str
): Timestamp when voting period ends
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
proposals = client.governance.get_proposals()
passed_proposals = client.governance.get_proposals(status="passed")
first_10 = client.governance.get_proposals(limit=10)
next_10 = client.governance.get_proposals(limit=10, offset=10)
voting_proposals = client.governance.get_proposals(
status="voting_period",
limit=5
)
for proposal in proposals:
print(f"Proposal {proposal['proposal_id']}: {proposal['title']}")
print(f"Status: {proposal['status']}")
print(f"Yes: {proposal['final_tally_result']['yes']}")
print(f"No: {proposal['final_tally_result']['no']}")
print("---")
get_proposal()¶
Retrieves detailed information about a specific governance proposal.
Required parameters:
proposal_id
(int
): Proposal ID to query
Returns: Dict
- Proposal information with the following fields:
proposal_id
(int
): Unique proposal identifierstatus
(int
): Proposal status codetitle
(str
): Proposal titledescription
(str
): Proposal descriptiontotal_deposit
(List[Dict]
): List of deposited coinsdenom
(str
): Token denominationamount
(str
): Deposit amount
voting_start_time
(str
): Timestamp when voting period startsvoting_end_time
(str
): Timestamp when voting period ends
Note: Returns an empty dictionary if the proposal is not found.
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
proposal = client.governance.get_proposal(42)
if proposal:
print(f"Proposal {proposal['proposal_id']}: {proposal['title']}")
print(f"Description: {proposal['description']}")
print(f"Status: {proposal['status']}")
print(f"Voting ends: {proposal['voting_end_time']}")
else:
print("Proposal not found")
get_proposal_votes()¶
Retrieves all votes for a specific proposal.
⚠️ Only works for proposals in voting stage.
def get_proposal_votes(proposal_id: int, limit: int = 100, offset: int = 0, count_total: bool = False) -> List[Dict[str, Any]]
Required parameters:
proposal_id
(int
): Proposal ID to query votes for
Optional parameters:
limit
(int
): Maximum number of results to return (default: 100)offset
(int
): Number of results to skip (default: 0)count_total
(bool
): Include total count in response (default: False)
Returns: List[Dict]
- List of votes, each containing:
proposal_id
(int
): Proposal identifiervoter
(str
): Address of the voteroption
(int
): Vote option (1=YES, 2=ABSTAIN, 3=NO, 4=NO_WITH_VETO)options
(List[Dict]
): List of weighted vote options (for weighted votes)option
(int
): Vote optionweight
(str
): Vote weight
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
votes = client.governance.get_proposal_votes(42)
recent_votes = client.governance.get_proposal_votes(42, limit=10)
first_100 = client.governance.get_proposal_votes(42, limit=100)
next_100 = client.governance.get_proposal_votes(42, limit=100, offset=100)
vote_options = {1: "YES", 2: "ABSTAIN", 3: "NO", 4: "NO_WITH_VETO"}
for vote in votes:
voter = vote['voter']
option = vote_options.get(vote['option'], "UNKNOWN")
print(f"{voter}: {option}")
print(f"Total votes: {len(votes)}")
get_vote()¶
Retrieves a specific vote from a voter on a proposal.
Required parameters:
proposal_id
(int
): Proposal ID to queryvoter_address
(str
): Address of the voter
Returns: Dict
- Vote information with the following fields:
proposal_id
(int
): Proposal identifiervoter
(str
): Address of the voteroption
(int
): Vote option (1=YES, 2=ABSTAIN, 3=NO, 4=NO_WITH_VETO)options
(List[Dict]
): List of weighted vote options (for weighted votes)option
(int
): Vote optionweight
(str
): Vote weight
Note: Returns an empty dictionary if no vote is found from the specified voter.
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
vote = client.governance.get_vote(
proposal_id=42,
voter_address="akash1qnnhhgzxj24f2kld5yhy4v4h4s9r295ak5gjw4"
)
if vote:
vote_options = {1: "YES", 2: "ABSTAIN", 3: "NO", 4: "NO_WITH_VETO"}
option = vote_options.get(vote['option'], "UNKNOWN")
print(f"Voted: {option}")
else:
print("No vote found from this address")
get_proposal_deposits()¶
Retrieves all deposits for a specific proposal.
Required parameters:
proposal_id
(int
): Proposal ID to query deposits for
Returns: List[Dict]
- List of deposits, each containing:
proposal_id
(int
): Proposal identifierdepositor
(str
): Address of the depositoramount
(List[Dict]
): List of deposited coinsdenom
(str
): Token denominationamount
(str
): Deposit amount
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
deposits = client.governance.get_proposal_deposits(42)
total_deposited = 0
for deposit in deposits:
depositor = deposit['depositor']
for coin in deposit['amount']:
amount = int(coin['amount'])
denom = coin['denom']
total_deposited += amount
print(f"{depositor}: {amount / 1_000_000:.6f} {denom.upper()}")
print(f"Total deposited: {total_deposited / 1_000_000:.6f} AKT")
get_proposal_tally()¶
Retrieves the current vote tally for a proposal.
Required parameters:
proposal_id
(int
): Proposal ID to get tally for
Returns: Dict
- Vote tally with the following fields:
yes
(str
): Total YES votes in base unitsabstain
(str
): Total ABSTAIN votes in base unitsno
(str
): Total NO votes in base unitsno_with_veto
(str
): Total NO_WITH_VETO votes in base units
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
tally = client.governance.get_proposal_tally(42)
yes_votes = int(tally['yes']) / 1_000_000
no_votes = int(tally['no']) / 1_000_000
abstain_votes = int(tally['abstain']) / 1_000_000
no_with_veto_votes = int(tally['no_with_veto']) / 1_000_000
print(f"Vote tally for proposal #42:")
print(f"Yes: {yes_votes:,.0f} AKT")
print(f"No: {no_votes:,.0f} AKT")
print(f"Abstain: {abstain_votes:,.0f} AKT")
print(f"No with Veto: {no_with_veto_votes:,.0f} AKT")
total_votes = yes_votes + no_votes + abstain_votes + no_with_veto_votes
if total_votes > 0:
print(f"Yes percentage: {(yes_votes / total_votes) * 100:.2f}%")
get_governance_params()¶
Retrieves governance module parameters for all parameter types.
Returns: Dict
- Governance parameters with the following fields:
voting_period
(str
): Voting period durationvoting_period_seconds
(int
): Voting period in secondsmax_deposit_period
(str
): Maximum deposit period durationmax_deposit_period_seconds
(int
): Maximum deposit period in secondsmin_deposit
(List[Dict]
): Minimum deposit required with denom and amountquorum
(str
): Quorum percentage requiredthreshold
(str
): Approval threshold percentageveto_threshold
(str
): Veto threshold percentage
Example:
from akash import AkashClient
client = AkashClient("https://akash-rpc.polkachu.com:443")
params = client.governance.get_governance_params()
print(f"Voting period: {params.get('voting_period_seconds', 0) / (24 * 60 * 60):.1f} days")
print(f"Quorum: {float(params.get('quorum', '0')) * 100:.2f}%")
print(f"Threshold: {float(params.get('threshold', '0')) * 100:.2f}%")
print(f"Veto threshold: {float(params.get('veto_threshold', '0')) * 100:.2f}%")
if 'min_deposit' in params:
for coin in params['min_deposit']:
amount = int(coin['amount']) / 1_000_000
denom = coin['denom']
print(f"Min deposit: {amount:,.0f} {denom.upper()}")