aea.crypto.ledger_apis

Module wrapping all the public and private keys cryptography.

LedgerApis

class LedgerApis()

Store all the ledger apis we initialise.

__init__

 | __init__(ledger_api_configs: Dict[str, Dict[str, Union[str, int]]], default_ledger_id: str)

Instantiate a wallet object.

Arguments:

  • ledger_api_configs: the ledger api configs.
  • default_ledger_id: the default ledger id.

configs

 | @property
 | configs() -> Dict[str, Dict[str, Union[str, int]]]

Get the configs.

apis

 | @property
 | apis() -> Dict[str, LedgerApi]

Get the apis.

has_ledger

 | has_ledger(identifier: str) -> bool

Check if it has a .

get_api

 | get_api(identifier: str) -> LedgerApi

Get the ledger API.

has_default_ledger

 | @property
 | has_default_ledger() -> bool

Check if it has the default ledger API.

last_tx_statuses

 | @property
 | last_tx_statuses() -> Dict[str, str]

Get last tx statuses.

default_ledger_id

 | @property
 | default_ledger_id() -> str

Get the default ledger id.

token_balance

 | token_balance(identifier: str, address: str) -> int

Get the token balance.

Arguments:

  • identifier: the identifier of the ledger
  • address: the address to check for

Returns:

the token balance

transfer

 | transfer(crypto_object: Crypto, destination_address: str, amount: int, tx_fee: int, tx_nonce: str, **kwargs) -> Optional[str]

Transfer from self to destination.

Arguments:

  • tx_nonce: verifies the authenticity of the tx
  • crypto_object: the crypto object that contains the fucntions for signing transactions.
  • destination_address: the address of the receive
  • amount: the amount
  • tx_fee: the tx fee

Returns:

tx digest if successful, otherwise None

send_signed_transaction

 | send_signed_transaction(identifier: str, tx_signed: Any) -> Optional[str]

Send a signed transaction and wait for confirmation.

Arguments:

  • tx_signed: the signed transaction

Returns:

the tx_digest, if present

is_transaction_settled

 | is_transaction_settled(identifier: str, tx_digest: str) -> bool

Check whether the transaction is settled and correct.

Arguments:

  • identifier: the identifier of the ledger
  • tx_digest: the transaction digest

Returns:

True if correctly settled, False otherwise

is_tx_valid

 | is_tx_valid(identifier: str, tx_digest: str, seller: Address, client: Address, tx_nonce: str, amount: int) -> bool

Kept for backwards compatibility!

is_transaction_valid

 | is_transaction_valid(identifier: str, tx_digest: str, seller: Address, client: Address, tx_nonce: str, amount: int) -> bool

Check whether the transaction is valid

Arguments:

  • identifier: Ledger identifier
  • tx_digest: the transaction digest
  • seller: the address of the seller.
  • client: the address of the client.
  • tx_nonce: the transaction nonce.
  • amount: the amount we expect to get from the transaction.

Returns:

True if is valid , False otherwise

generate_tx_nonce

 | generate_tx_nonce(identifier: str, seller: Address, client: Address) -> str

Generate a random str message.

Arguments:

  • identifier: ledger identifier.
  • seller: the address of the seller.
  • client: the address of the client.

Returns:

return the hash in hex.