Ecosystems
- class ape_starknet.ecosystems.ProxyType(value)
An enumeration.
- class ape_starknet.ecosystems.Starknet(*, name: str, data_folder: Path, request_header: dict, fee_token_symbol: str = 'ETH', proxy_info_cache: Dict[ChecksumAddress, Optional[StarknetProxy]] = {})
The Starknet
EcosystemAPI
implementation.- create_transaction(**kwargs) TransactionAPI
Create a transaction using key-value arguments.
- Parameters:
**kwargs – Everything the transaction needs initialize.
- Returns:
~ape.api.transactions.TransactionAPI
- Return type:
class
- classmethod decode_address(raw_address: Union[str, int, HexBytes]) ChecksumAddress
Make a checksum address given a supported format. Borrowed from
eth_utils.to_checksum_address()
but supports non-length 42 addresses. :param raw_address: The value to convert. :type raw_address: Union[int, str, bytes]- Returns:
The converted address.
- Return type:
AddressType
- decode_block(block: StarknetBlock) BlockAPI
Decode data to a
BlockAPI
.- Parameters:
data (dict) – A dictionary of data to decode.
- Returns:
BlockAPI
- decode_calldata(abi: Union[ConstructorABI, MethodABI], calldata: bytes) Dict
Decode method calldata.
- Parameters:
abi (MethodABI) – The method called.
calldata (bytes) – The raw calldata bytes.
- Returns:
A mapping of input names to decoded values. If an input is anonymous, it should use the stringified index of the input as the key.
- Return type:
Dict
- decode_logs(logs: List[Dict], *events: EventABI) Iterator[ContractLog]
Decode any contract logs that match the given event ABI from the raw log data.
- Parameters:
logs (List[Dict]) – A list of raw log data from the chain.
*events (EventABI) – Event definitions to decode.
- Returns:
Iterator[
ContractLog
]
- decode_primitive_value(value: Any, output_type: Union[str, Tuple, List] = 'felt') int
Decodes the value to given to an integer.
- Parameters:
value (Any) – The given value to be changed.
- Returns:
The integer value of the value given.
- Return type:
int
- decode_receipt(data: dict) ReceiptAPI
Convert data to
ReceiptAPI
.- Parameters:
data (dict) – A dictionary of Receipt properties.
- Returns:
ReceiptAPI
- decode_returndata(abi: MethodABI, raw_data: List[int]) Any
Get the result of a contract call.
- Arg:
abi (MethodABI): The method called. raw_data (bytes): Raw returned data.
- Returns:
All of the values returned from the contract function.
- Return type:
Any
- classmethod encode_address(address: Union[ChecksumAddress, str]) int
Convert the ecosystem’s native address type to a raw integer or str address.
- Parameters:
address (Union[str, int]) – The address to convert.
- Returns:
Union[str, int]
- encode_calldata(abi: Union[ConstructorABI, MethodABI], *args) List
Encode method calldata.
- Parameters:
abi (Union[ConstructorABI, MethodABI]) – The ABI of the method called.
*args (Any) – The arguments given to the method.
- Returns:
The encoded calldata of the arguments to the given method.
- Return type:
HexBytes
- encode_contract_blueprint(contract: Union[ContractContainer, ContractType], *args, **kwargs) DeclareTransaction
Encodes the contract blueprint
- Parameters:
contract (Union[ContractContainer, ContractType]) – The contract to be encoded.
- Returns:
DeclareTransaction
- encode_deployment(deployment_bytecode: HexBytes, abi: ConstructorABI, *args, **kwargs) TransactionAPI
Create a deployment transaction in the given ecosystem. This may require connecting to other networks.
- Parameters:
deployment_bytecode (HexBytes) – The bytecode to deploy.
abi (ConstructorABI) – The constructor interface of the contract.
*args – Constructor arguments.
**kwargs – Transaction arguments.
- Returns:
~ape.api.transactions.TransactionAPI
- Return type:
class
- encode_primitive_value(value: Any) int
Encodes the given value to int.
- Parameters:
value (Any) – The given value to be changed to int.
- encode_transaction(address: ChecksumAddress, abi: MethodABI, *args, **kwargs) TransactionAPI
Encode a transaction object from a contract function’s abi and call arguments. Update the transaction arguments with the overrides in
kwargs
as well.- Parameters:
address (AddressType) – The address of the contract.
abi (MethodABI) – The function to call on the contract.
*args – Function arguments.
**kwargs – Transaction arguments.
- Returns:
~ape.api.transactions.TransactionAPI
- Return type:
class
- fee_token_symbol: str
The token symbol for the currency that pays for fees, such as ETH.
- get_proxy_info(address: ChecksumAddress) Optional[StarknetProxy]
Information about a proxy contract such as proxy type and implementation address.
- Parameters:
address (str) – The address of the contract.
- Returns:
Returns
None
if the contract does not use any known proxy pattern.- Return type:
Optional[
ProxyInfoAPI
]
- serialize_transaction(transaction: TransactionAPI) bytes
Serialize a transaction to bytes.
- Parameters:
transaction (
TransactionAPI
) – The transaction to encode.- Returns:
bytes
- class ape_starknet.ecosystems.StarknetBlock(*, num_transactions: int = 0, hash: Optional[int] = None, number: Optional[int] = None, parentHash: Any = 0, size: int, timestamp: int)