When using custom types in Starknet contract entrypoints, you need to handle serialization and deserialization of data. This is because:Documentation Index
Fetch the complete documentation index at: https://docs.starknet.io/llms.txt
Use this file to discover all available pages before exploring further.
- Input parameters are sent to entrypoints as arrays of
felt252 - Return values must be converted back to arrays of
felt252 - Custom types need to be converted between these formats automatically
Using the Serde Trait
TheSerde trait provides the necessary serialization and deserialization capabilities for your custom types. For most simple types, you can derive this trait automatically:
For some complex types, you might need to implement the
Serde trait manually. This gives you control over how your type is serialized and deserialized.The Serde trait is distinct from the Store trait - Serde is for passing data in and out of entrypoints, while Store is for persisting data in contract storage.