Network and Contracts
get_
ledger
def get_ledger() -> LedgerClient
Get the Ledger client.
Returns:
LedgerClient
- The Ledger client instance.
get_
faucet
def get_faucet() -> FaucetApi
Get the Faucet API instance.
Returns:
FaucetApi
- The Faucet API instance.
wait_
for_
tx_
to_
complete
async def wait_for_tx_to_complete(
tx_hash: str,
timeout: Optional[timedelta] = None,
poll_period: Optional[timedelta] = None) -> TxResponse
Wait for a transaction to complete on the Ledger.
Arguments:
tx_hash
str - The hash of the transaction to monitor.timeout
Optional[timedelta], optional - The maximum time to wait for the transaction to complete. Defaults to None.poll_period
Optional[timedelta], optional - The time interval to poll the Ledger for the transaction status. Defaults to None.
Returns:
TxResponse
- The response object containing the transaction details.
AlmanacContract Objects
class AlmanacContract(LedgerContract)
A class representing the Almanac contract for agent registration.
This class provides methods to interact with the Almanac contract, including checking if an agent is registered, retrieving the expiry height of an agent's registration, and getting the endpoints associated with an agent's registration.
is_
registered
def is_registered(address: str) -> bool
Check if an agent is registered in the Almanac contract.
Arguments:
address
str - The agent's address.
Returns:
bool
- True if the agent is registered, False otherwise.
get_
expiry
def get_expiry(address: str) -> int
Get the expiry height of an agent's registration.
Arguments:
address
str - The agent's address.
Returns:
int
- The expiry height of the agent's registration.
get_
endpoints
def get_endpoints(address: str)
Get the endpoints associated with an agent's registration.
Arguments:
address
str - The agent's address.
Returns:
Any
- The endpoints associated with the agent's registration.
get_
protocols
def get_protocols(address: str)
Get the protocols associated with an agent's registration.
Arguments:
address
str - The agent's address.
Returns:
Any
- The protocols associated with the agent's registration.
register
async def register(ledger: LedgerClient, wallet: LocalWallet,
agent_address: str, protocols: List[str],
endpoints: List[Dict[str, Any]], signature: str)
Register an agent with the Almanac contract.
Arguments:
ledger
LedgerClient - The Ledger client.wallet
LocalWallet - The agent's wallet.agent_address
str - The agent's address.protocols
List[str] - List of protocols.endpoints
List[Dict[str, Any]] - List of endpoint dictionaries.signature
str - The agent's signature.
get_
sequence
def get_sequence(address: str) -> int
Get the agent's sequence number for Almanac registration.
Arguments:
address
str - The agent's address.
Returns:
int
- The agent's sequence number.
get_
almanac_
contract
def get_almanac_contract() -> AlmanacContract
Get the AlmanacContract instance.
Returns:
AlmanacContract
- The AlmanacContract instance.
NameServiceContract Objects
class NameServiceContract(LedgerContract)
A class representing the NameService contract for managing domain names and ownership.
This class provides methods to interact with the NameService contract, including checking name availability, checking ownership, querying domain public status, obtaining registration transaction details, and registering a name within a domain.
is_
name_
available
def is_name_available(name: str, domain: str)
Check if a name is available within a domain.
Arguments:
name
str - The name to check.domain
str - The domain to check within.
Returns:
bool
- True if the name is available, False otherwise.
is_
owner
def is_owner(name: str, domain: str, wallet_address: str)
Check if the provided wallet address is the owner of a name within a domain.
Arguments:
name
str - The name to check ownership for.domain
str - The domain to check within.wallet_address
str - The wallet address to check ownership against.
Returns:
bool
- True if the wallet address is the owner, False otherwise.
is_
domain_
public
def is_domain_public(domain: str)
Check if a domain is public.
Arguments:
domain
str - The domain to check.
Returns:
bool
- True if the domain is public, False otherwise.
get_
registration_
tx
def get_registration_tx(name: str, wallet_address: str, agent_address: str,
domain: str)
Get the registration transaction for registering a name within a domain.
Arguments:
name
str - The name to be registered.wallet_address
str - The wallet address initiating the registration.agent_address
str - The address of the agent.domain
str - The domain in which the name is registered.
Returns:
Optional[Transaction]
- The registration transaction, or None if the name is not available or not owned by the wallet address.
register
async def register(ledger: LedgerClient, wallet: LocalWallet,
agent_address: str, name: str, domain: str)
Register a name within a domain using the NameService contract.
Arguments:
ledger
LedgerClient - The Ledger client.wallet
LocalWallet - The wallet of the agent.agent_address
str - The address of the agent.name
str - The name to be registered.domain
str - The domain in which the name is registered.
get_
name_
service_
contract
def get_name_service_contract() -> NameServiceContract
Get the NameServiceContract instance.
Returns:
NameServiceContract
- The NameServiceContract instance.