Client#
Base class for clients interacting with Starknet. Implemented by FullNodeClient.
- class starknet_py.net.client.Client#
- abstract async call_contract(call: Call, block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) List[int] #
Call the contract with given instance of InvokeTransaction
- Parameters:
call – Call
block_hash – Block’s hash or literals “pending” or “latest”
block_number – Block’s number or literals “pending” or “latest”
- Returns:
List of integers representing contract’s function output (structured like calldata)
- abstract call_contract_sync(call: Call, block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) List[int] #
Synchronous version of the method.
- abstract async declare(transaction: DeclareV1 | DeclareV2 | DeclareV3) DeclareTransactionResponse #
Send a declare transaction
- Parameters:
transaction – Declare transaction
- Returns:
SentTransactionResponse object
- abstract declare_sync(transaction: DeclareV1 | DeclareV2 | DeclareV3) DeclareTransactionResponse #
Synchronous version of the method.
- abstract async deploy_account(transaction: DeployAccountV1 | DeployAccountV3) DeployAccountTransactionResponse #
Deploy a pre-funded account contract to the network
- Parameters:
transaction – DeployAccount transaction
- Returns:
SentTransactionResponse object
- abstract deploy_account_sync(transaction: DeployAccountV1 | DeployAccountV3) DeployAccountTransactionResponse #
Synchronous version of the method.
- abstract async estimate_fee(tx: AccountTransaction | List[AccountTransaction], skip_validate: bool = False, block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) EstimatedFee | List[EstimatedFee] #
Estimates the resources required by a given sequence of transactions when applied on a given state. If one of the transactions reverts or fails due to any reason (e.g. validation failure or an internal error), a TRANSACTION_EXECUTION_ERROR is returned. For v0-2 transactions the estimate is given in Wei, and for v3 transactions it is given in Fri.
- Parameters:
tx – Transaction to estimate
skip_validate – Flag checking whether the validation part of the transaction should be executed.
block_hash – Block’s hash or literals “pending” or “latest”.
block_number – Block’s number or literals “pending” or “latest”.
- Returns:
Estimated amount of Wei executing specified transaction will cost.
- abstract estimate_fee_sync(tx: AccountTransaction | List[AccountTransaction], skip_validate: bool = False, block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) EstimatedFee | List[EstimatedFee] #
Synchronous version of the method.
- abstract async get_block(block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) StarknetBlock | PendingStarknetBlock #
Retrieve the block’s data by its number or hash
- Parameters:
block_hash – Block’s hash or literals “pending” or “latest”
block_number – Block’s number or literals “pending” or “latest”
- Returns:
StarknetBlock object representing retrieved block
- abstract get_block_sync(block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) StarknetBlock | PendingStarknetBlock #
Synchronous version of the method.
- abstract async get_chain_id() str #
Return the currently configured Starknet chain id
- abstract get_chain_id_sync() str #
Synchronous version of the method.
- abstract async get_class_by_hash(class_hash: int | str) DeprecatedContractClass | SierraContractClass #
Get the contract class for given class hash
- Parameters:
class_hash – Class hash
- Returns:
ContractClass object
- abstract get_class_by_hash_sync(class_hash: int | str) DeprecatedContractClass | SierraContractClass #
Synchronous version of the method.
- abstract async get_class_hash_at(contract_address: int | str, block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) int #
Get the contract class hash for the contract deployed at the given address
- Parameters:
contract_address – Address of the contract whose class hash is to be returned
block_hash – Block’s hash or literals “pending” or “latest”
block_number – Block’s number or literals “pending” or “latest”
- Returns:
Class hash
- abstract get_class_hash_at_sync(contract_address: int | str, block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) int #
Synchronous version of the method.
- abstract async get_contract_nonce(contract_address: int, block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) int #
Get the latest nonce associated with the given address
- Parameters:
contract_address – Get the latest nonce associated with the given address
block_hash – Block’s hash or literals “pending” or “latest”
block_number – Block’s number or literals “pending” or “latest”
- Returns:
The last nonce used for the given contract
- abstract get_contract_nonce_sync(contract_address: int, block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) int #
Synchronous version of the method.
- abstract async get_state_update(block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) BlockStateUpdate | PendingBlockStateUpdate #
Get the information about the result of executing the requested block
- Parameters:
block_hash – Block’s hash or literals “pending” or “latest”
block_number – Block’s number or literals “pending” or “latest”
- Returns:
BlockStateUpdate object representing changes in the requested block
- abstract get_state_update_sync(block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) BlockStateUpdate | PendingBlockStateUpdate #
Synchronous version of the method.
- abstract async get_storage_at(contract_address: int | str, key: int, block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) int #
- Parameters:
contract_address – Contract’s address on Starknet
key – An address of the storage variable inside the contract.
block_hash – Block’s hash or literals “pending” or “latest”
block_number – Block’s number or literals “pending” or “latest”
- Returns:
Storage value of given contract
- abstract get_storage_at_sync(contract_address: int | str, key: int, block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) int #
Synchronous version of the method.
- abstract async get_transaction(tx_hash: int | str) Transaction #
Get the details and status of a submitted transaction
- Parameters:
tx_hash – Transaction’s hash
- Returns:
Transaction object
- abstract async get_transaction_receipt(tx_hash: int | str) TransactionReceipt #
Get the transaction receipt
- Parameters:
tx_hash – Transaction’s hash
- Returns:
Transaction receipt object on Starknet
- abstract get_transaction_receipt_sync(tx_hash: int | str) TransactionReceipt #
Synchronous version of the method.
- abstract async get_transaction_status(tx_hash: int | str) TransactionStatusResponse #
Gets the transaction status (possibly reflecting that the transaction is still in the mempool, or dropped from it).
- Parameters:
tx_hash – Hash of the executed transaction.
- Returns:
Finality and execution status of a transaction.
- abstract get_transaction_status_sync(tx_hash: int | str) TransactionStatusResponse #
Synchronous version of the method.
- abstract get_transaction_sync(tx_hash: int | str) Transaction #
Synchronous version of the method.
- abstract async send_transaction(transaction: InvokeV1 | InvokeV3) SentTransactionResponse #
Send a transaction to the network
- Parameters:
transaction – Transaction object (i.e. Invoke).
- Returns:
SentTransactionResponse object
- abstract send_transaction_sync(transaction: InvokeV1 | InvokeV3) SentTransactionResponse #
Synchronous version of the method.
- abstract async trace_block_transactions(block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) List[BlockTransactionTrace] #
Receive the traces of all the transactions within specified block
- Parameters:
block_hash – Block’s hash
block_number – Block’s number or “pending” for pending block
- Returns:
BlockTransactionTraces object representing received traces
- abstract trace_block_transactions_sync(block_hash: int | str | Literal['pending', 'latest'] | None = None, block_number: int | Literal['pending', 'latest'] | None = None) List[BlockTransactionTrace] #
Synchronous version of the method.
- async wait_for_tx(tx_hash: int | str, check_interval: float = 2, retries: int = 500) TransactionReceipt #
Awaits for transaction to get accepted or at least pending by polling its status.
- Parameters:
tx_hash – Transaction’s hash.
check_interval – Defines interval between checks.
retries – Defines how many times the transaction is checked until an error is thrown.
- Returns:
Transaction receipt.
- wait_for_tx_sync(tx_hash: int | str, check_interval: float = 2, retries: int = 500) TransactionReceipt #
Synchronous version of the method.