Decode#
- nethermind.starknet_abi.decode.decode_core_type(decode_type: StarknetCoreType, calldata: list[int]) str | int | bool #
Decodes Calldata using Starknet Core Type. Takes in two parameters, a StarknetCoreType, and a mutable reference to a calldata array. When decoding, calldata is popped off the top of the calldata array. This reference to the calldata array is recursively passed between type decoders, so this array is modified during decoding
- Parameters:
decode_type – Starknet Core Type to Decode
calldata – Mutable reference to calldata array. WARN – Array is Consumed by Method
- nethermind.starknet_abi.decode.decode_from_params(params: Sequence[AbiParameter], calldata: list[int]) dict[str, Any] #
Decodes Calldata using AbiParameters, which have names and types
Warning
Calldata list is consumed during decoding, as calldata is recursively popped off the top of the calldata throughout the decoding process
>>> from nethermind.starknet_abi.decode import AbiParameter, decode_from_params, StarknetCoreType >>> decode_from_params( ... [AbiParameter("a", StarknetCoreType.U32), AbiParameter("b", StarknetCoreType.U32)], ... [123456, 654321] ... ) {'a': 123456, 'b': 654321}
- Parameters:
params – Sequence of AbiParameters
calldata – Mutable calldata Array
- Returns:
Dict mapping Parameter names to decoded types
- nethermind.starknet_abi.decode.decode_from_types(types: Sequence[StarknetCoreType | StarknetOption | StarknetTuple | StarknetArray | StarknetStruct | StarknetEnum], calldata: list[int]) list[Any] #
Decodes calldata array using a list of StarknetTypes.
Warning
The calldata array passed to decode_from_types is mutated during decoding. Calldata is recursively popped off the stack as decoding occurs
- Parameters:
types – Sequence of StarknetType to decode
calldata – Mutable Array of Calldata