pragma_sdk.onchain#

PragmaOnChainClient#

class pragma_sdk.onchain.client.PragmaOnChainClient[source]#

Bases: PragmaClient, NonceMixin, OracleMixin, PublisherRegistryMixin, RandomnessMixin, MerkleFeedMixin

Client for interacting with Pragma on Starknet.

Parameters:
  • network – Target network for the client. Can be a URL string, or one of "mainnet", "sepolia" or "devnet"

  • account_private_key – Optional private key for requests. Not necessary if not making network updates. Can be either an hexadecimal string 0x prefixed, an integer or a KeyStore type. The KeyStore is a tuple of two string [str, str], which are [“path/to/the/keystore”, “password_to_unlock_the_keystore”].

  • account_contract_address – Optional account contract address. Not necessary if not making network updates. Can either be an integer or an hexadecimal string 0x prefixed.

  • contract_addresses_config – Optional Contract Addresses for Pragma contracts. Will default to the provided network but must be set if using non standard contracts.

  • port – Optional port to interact with local node. Will default to 5050.

  • chain_name – A str-representation of the chain if a URL string is given for network. Must be one of "mainnet", "sepolia" or "devnet".

__init__(network: Annotated[Url, UrlConstraints(max_length=2083, allowed_schemes=['http', 'https'], host_required=None, default_host=None, default_port=None, default_path=None)] | Literal['devnet', 'mainnet', 'sepolia'] = 'sepolia', account_private_key: int | str | Tuple[str, str] | None = None, account_contract_address: int | str | None = None, contract_addresses_config: ContractAddresses | None = None, port: int | None = None, chain_name: Literal['devnet', 'mainnet', 'sepolia'] | None = None, execution_config: ExecutionConfig | None = None)[source]#
account: Account = None#
property account_address: int#

Return the account address.

account_contract_address: int | None = None#
client: Client = None#
execution_config: ExecutionConfig#
full_node_client: FullNodeClient = None#
async get_balance(account_contract_address, token_address=None) int[source]#

Get the balance of an account given the account contract address and token address.

Parameters:
  • account_contract_address – The account contract address.

  • token_address – The token address. If None, will use ETH as the token address.

Returns:

The balance of the account.

async get_block_number() Any[source]#

Returns the current block number.

init_stats_contract(stats_contract_address: int)[source]#

Initialize the Summary Stats contract.

is_user_client: bool = False#
async publish_entries(entries: List[Entry]) Tuple[Dict | None, Dict | None] | List[InvokeResult][source]#

Publish entries on-chain.

Parameters:

entries – List of Entry objects

Returns:

List of InvokeResult objects