Map
type in starknet::storage
is specifically designed for contract storage for this purpose.
Here’s a simple example that demonstrates how to use a Map
:
Map<KeyType, ValueType>
syntaxStorage
struct
StorageMapReadAccess
and StorageMapWriteAccess
traits from starknet::storage
write(key, value)
: Stores a value for a given keyread(key)
: Retrieves the value associated with a key