Mappings in Solidity are hash tables that store data as key-value pairs, where the key can be any of the built-in data types supported by Ethereum.
Here we will give you the example of mapping in Stylus Rust SDK.
Maps are created with the syntax StorageMap<keyType, StorageType> (rust syntax) or mapping(keyType => valueType) (solidity syntax).
If you define with rust syntax, the keyType should be the type from alloy_primitives, valueType can be be any type from StorageType.
If you define with solidity syntax, the keyType can be any built-in value type, bytes, string, or any contract, valueType can be any type including another mapping or an array.
Mappings are not iterable.
1Loading...1Loading...1Loading...1Loading...1Loading...1Loading...