Map
.
Enables directly storing values in the contract’s storage at the address of the given key.
pub trait StorageMapWriteAccess
use starknet::ContractAddress;
use starknet::storage::{Map, StorageMapWriteAccess, StoragePathEntry};
#[storage]
struct Storage {
balances: Map,
allowances: Map>,
}
fn write_storage(ref self: ContractState, address: ContractAddress) {
// Write to single mapping
self.balances.write(address, 100);
// Write to nested mapping
self.allowances.entry(owner).write(spender, 50);
}
fn write(self: TMemberState, key: Self::Key, value: Self::Value)
type Key;
type Value;