AbiEncodeTrait
Fully qualified path: alexandria_evm::encoder::AbiEncodeTrait
pub trait AbiEncodeTrait
Trait functions
encode
Encodes felt252 values into EVM calldata for the specified types.
This function is the primary entry point for encoding values into EVM-compatible calldata in Starknet Cairo. It accepts a list of EVM-compatible types and a corresponding list of felt252 values, then encodes them according to EVM ABI encoding standards.
This function is typically implemented as a dispatcher that calls appropriate encoding
routines (e.g., encode_uint, encode_tuple, encode_array, etc.) based on the types
passed in.
Arguments
self- Reference toEVMCalldatacontext which maintains the calldata byte array, current offset, dynamic data section and dynamic offset.types- A list (Span) ofEVMTypesto encode.values- A list (Span) offelt252values to encode according to the types.
Returns
ByteArray- The encoded EVM calldata as a byte array.
Usage
This function is typically called when preparing calldata for EVM contract calls from within Cairo smart contracts.
Fully qualified path: alexandria_evm::encoder::AbiEncodeTrait::encode
fn encode(ref self: EVMCalldata, types: Span<EVMTypes>, values: Span<felt252>) -> ByteArray