Skip to Content
ReferencesCosmPy References

CosmPy References

cosmpy.aerial.exceptions

Exceptions

QueryError Objects

class QueryError(RuntimeError)

Invalid Query Error.

NotFoundError Objects

class NotFoundError(QueryError)

Not found error.

QueryTimeoutError Objects

class QueryTimeoutError(RuntimeError)

Query timeout error.

BroadcastError Objects

class BroadcastError(RuntimeError)

Broadcast error.

init

def __init__ (tx_hash: str, message: str)

Init Broadcast error.

Arguments:

  • tx_hash: transaction hash.
  • message: message.

OutOfGasError Objects

class OutOfGasError(BroadcastError)

Insufficient fees error.

init

def __init__(tx_hash: str, gas_wanted: int, gas_used: int)

Initialize.

Arguments:

  • tx_hash: transaction hash.
  • gas_wanted: gas required to complete the transaction.
  • gas_used: gas used.

InsufficientFeesError Objects

class InsufficientFeesError(BroadcastError)

init

def __init__(tx_hash: str, minimum_required_fee: str)

Initialize.

Arguments:

  • tx_hash: transaction hash.
  • minimum_required_fee: minimum required fee.

cosmpy.aerial.faucet

Ledger faucet API Interface.

FaucetAPI Objects

Faucet API

init

def __init__ (net_config: NetworkConfig)

Init faucet API.

Arguments:

  • net_config: Ledger network configuration.

Raises:

  • ValueError: Network config has no faucet URL set.

get_wealth

def get_wealth(address: Union[Address, str]) -> None

Get wealth from the faucet for the provided address.

Arguments:

  • address: the address.

Raises:

  • RuntimeError: Unable to create faucet claim.
  • RuntimeError: Failed to check faucet claim status.
  • RuntimeError: Failed to get wealth for address.
  • ValueError: Faucet claim check timed out.

cosmpy.aerial.config

Network configurations.

NetworkConfigError Objects

class NetworkConfigError(RuntimeError)

Network config error.

Arguments:

  • RuntimeError: Runtime error.

NetworkConfig Objects

@dataclass class NetworkConfig()

Network configurations.

Raises:

  • NetworkConfigError: Network config error.
  • RuntimeError: Runtime error.

validate

def validate()

Validate network configuration.

Raises:

  • NetworkConfigError: Network config error.

fetchai_dorado_testnet

@classmethod def fetchai_dorado_testnet(cls) -> "Network Config"

Fetch.ai Dorado Testnet.

Returns:

Network configuration.

fetchai_alpha_testnet

@classmethod def fetchai_alpha_testnet(cls)

Get Fetch.ai alpha Testnet.

Raises:

  • RuntimeError: No beta Testnet available.

fetchai_stable_testnet

@classmethod def fetchai_stable_testnet(cls)

Get Fetch.ai stable Testnet.

Returns:

Fetch.ai stable Testnet. For now Dorado is Fetch.ai stable Testnet.

fetchai_mainnet

@classmethod def fetchai_mainnet(cls) -> "NetworkConfig"

Get the Fetch.ai Mainnet configuration.

Returns:

Fetch.ai Mainnet configuration.

fetch_mainnet

@classmethod def fetch_mainnet(cls) -> "NetworkConfig"

Get the Fetch.ai Mainnet.

Returns:

Fetch.ai Mainnet configurations.

latest_stable_testnet

@classmethod def latest_stable_testnet(cls) -> "NetworkConfig"

Get the latest stable Testnet.

Returns:

Latest stable Testnet.

cosmpy.aerial.coins

Parse the coins.

parse_coins

def parse_coins(value: str) -> List[Coin]

Arguments:

  • value: coins.

Raises:

  • RuntimeError: If unable to parse the value.

Returns:

Coins.

cosmpy.aerial.urls

Parsing the URL.

Protocol Objects

class Protocol(Enum)

Protocol Enum.

Arguments:

  • Enum: Enum.

ParsedUrl Objects

@dataclass class ParsedUrl()

Parse URL.

Returns:

Parsed URL.

rest_url

@property def rest_url() -> Str

Get the rest URL.

Returns:

rest urls.

parse_url

def parse_url(url: str) -> ParsedUrl

Initialize.

Arguments:

  • URL: URL.

Raises:

  • RuntimeError: If URL scheme is unsupported.

Returns:

Parsed URL.

cosmpy.aerial.tx

Transaction.

TxState Objects

class TxState(Enum)

Transaction state.

Arguments:

  • Enum: Draft, Sealed, Final.

SigningMode Objects

class SigningMode(Enum)

Signing Mode.

Arguments:

  • Enum: Direct.

SigningConfig Objects

@dataclass class SigningCfg()

Transaction signing configuration.

Direct

@staticmethod def direct(public_key: PublicKey, sequence_num: int) -> "SigningCfg"

Transaction signing configuration using Direct Mode.

Arguments:

  • public_key: Public key.
  • sequence_num: Sequence number.

Returns:

Transaction signing configuration.

Transaction Objects

class Transaction()

Transaction.

init

def __init__()

Init the transaction with transaction message, state, fee and body.

State

@property def state() -> TxState

Get the transaction state.

Returns:

Current state of the transaction.

Msgs

@property def msgs()

Get the transaction messages.

Returns:

Transaction messages.

fee

@property def fee() -> Optional[str]

Get the transaction fee.

Returns:

Transaction fee.

tx

@property def tx()

Initialize.

Raises:

  • RuntimeError: If the transaction has not been completed.

Returns:

Transaction.

add_message

def add_message(msg: Any) -> "Transaction"

Initialize.

Arguments:

  • msg: Transaction message(memo).

Raises:

  • RuntimeError: If the transaction is not in the draft state.

Returns:

Transaction with message added.

Seal

def seal(signing_cfgs: Union[signing_cfg, List[SigningCfg]], fee: str, gas_limit: int, memo: Optional[str] = None) -> "Transaction"

Seal the transaction.

Arguments:

  • signing_cfgs: signing configs.
  • fee: transaction fee.
  • gas_limit: transaction gas limit.
  • memo: transaction memo, defaults to None.

Returns: Sealed transaction.

sign

def sign(signer: Signer, chain_id: str, account_number: int, deterministic: bool = False) -> "Transaction"

Sign the transaction.

Arguments:

  • signer: signer.
  • chain_id: chain id.
  • account_number: account number.
  • deterministic: deterministic, defaults to False.

Raises:

  • RuntimeError: If transaction is not sealed.

Returns:

Signed transaction

complete

def complete() -> "Transaction"

Update transaction state to Final.

Returns:

Transaction with updated state.

cosmpy.aerial.gas

Transaction gas strategy.

Gas Strategy Objects

class GasStrategy(ABC)

Transaction gas strategy.

estimate_gas

@abstractmethod def estimate_gas(tx: Transaction) -> int

Estimate the transaction gas.

Arguments:

  • tx: Transaction.

Returns:

None.

block_gas_limit

@abstractmethod def block_gas_limit() -> int

Get the block gas limit.

Returns:

None.

SimulationGasStrategy Objects

Simulation transaction gas strategy.

Arguments:

  • GasStrategy: gas strategy.

init

def __init__(client: "LedgerClient", multiplier: Optional[float] = None)

Init the simulation transaction gas strategy.

Arguments:

  • client: ledger client.
  • multiplier: multiplier, defaults to None.

estimate_gas

def estimate_gas(tx: Transaction) -> int

Get estimated transaction gas.

Arguments:

  • tx: transaction.

Returns:

Estimated transaction gas.

block_gas_limit

def block_gas_limit() ->int

Get the block gas limit.

Returns:

Block gas limit.

OfflineMessageTableStrategy Objects

class OfflineMessageTableStrategy(GasStrategy)

Offline message table strategy.

Arguments:

  • GasStrategy: gas strategy.

default_table

@staticmethod def default_table() ->"OfflineMessageTableStrategy"

Offline message strategy default table.

Returns:

Offline message default table strategy.

init

def __init__ (fallback_gas_limit: Optional[int] = None, block_limit: Optional[int] = None)

Init offline message table strategy.

Arguments:

  • fallback_gas_limit: fallback gas limit, defaults to None.
  • block_limit: block limit, defaults to None.

update_entry

def update_entry(transaction_type: str, gas_limit: int)

Update the entry of the transaction.

Arguments:

  • tx: transaction.

Returns:

Estimated transaction gas.

block_gas_limit

def block_gas_limit() ->int

Get the block gas limit.

Returns:

Block gas limit.

cosmpy.aerial.tx_helpers

Transaction helpers.

MessageLog Objects

@dataclass class MessageLog()

Message MessageLog.

TxResponse Objects

@dataclass class TxResponse()

Transaction response.

Raises:

  • OutOfGasError: out of gas error.
  • InsufficientFeesError: insufficient fees.
  • BroadcastError: broadcast exception.

is_successful

def is_successful() -> bool

Checks if transaction is is_successful.

Raises:

  • OutOfGasError: out of gas error.
  • InsufficientFeesError: insufficient fees.
  • BroadcastError: broadcast exception.

SubmittedTx Objects

class SubmittedTx()

Submitted transaction.

init

def __init__(client: "LedgerClient", tx_hash: str)

Init the submitted transaction.

Arguments:

  • client: ledger Client.
  • tx_hash: transaction hash.

tx_hash

@property def tx_hash() -> str

Returns:

Transaction hash.

response

@property def response() -> Optional[TxResponse]

Get the transaction response.

Returns:

Response.

contract_code_id

@property def contract_code_id() -> Optional[int]

Get the contract code id.

Returns:

Return contract code id if exists, else None.

contract_address

@property def contract_address() -> Optional[Address]

Get the contract address.

Returns:

Return contract address if it exists, else return None.

wait_to_complete

def wait_to_complete( timeout: Optional[Union[int, float, timedelta]] = None, poll_period: Optional[Union[int, float, timedelta]] = None ) -> "SubmittedTx"

Wait to complete the transaction.

Arguments:

  • timeout: timeout, defaults to None.
  • poll_period: poll period, defaults to None.

Returns:

Submitted transaction.

cosmpy.aerial.wallet

Wallet generation.

Wallet Objects

class Wallet(ABC, UserString)

Wallet generation.

Arguments:

  • ABC: ABC abstract method.
  • UserString: user string.

Address

@abstractmethod def address() -> Address

Get the address of the wallet.

Returns:

None.

public_key

@abstractmethod def public_key() -> PublicKey

Get the public key of the wallet.

Returns:

None.

Signer

@abstractmethod def signer() -> Signer

Get the signer of the wallet.

Returns: None.

data

@property def data()

Get the address of the wallet.

Returns: Address.

json

def __json__()

Return the address in string format.

Returns:

Address in string format.

LocalWallet Objects

class LocalWallet(Wallet)

Generate local wallet.

Arguments:

  • Wallet: wallet.

Generate

@staticmethod def generate(prefix: Optional[str] = None) -> "LocalWallet"

Generate local wallet.

Arguments:

  • prefix: prefix, defaults to None.

Returns:

Local wallet.

from_mnemonic

@staticmethod def from_mnemonic( mnemonic: str, prefix: Optional[str] = None ) -> "LocalWallet"

Generate local wallet from mnemonic.

Arguments:

  • mnemonic: mnemonic.
  • prefix: prefix, defaults to None.

Returns:

Local wallet.

from_unsafe_seed

@staticmethod def from_unsafe_seed( text: str, index: Optional[int] = None, prefix: Optional[str] = None ) -> "LocalWallet"

Generate local wallet from unsafe seed.

Arguments:

  • text: text.
  • index: index, defaults to None.
  • prefix: prefix, defaults to None.

Returns:

Local wallet.

init

def __init__(private_key: PrivateKey, prefix: Optional[str] = None)

Init wallet with.

Arguments:

  • private_key: private key of the wallet.
  • prefix: prefix, defaults to None.

address

def address() -> Address

Get the wallet address.

Returns:

Wallet address.

public_key

def public_key() ->PublicKey

Get the public key of the wallet.

Returns:

Public key.

signer

def signer() -> PrivateKey

Get the signer of the wallet.

Returns:

Signer.

Last updated on