Create and use a storage Map
Learn how to write into a storage map.
#
GoalLearn how to use a StorageMap
using FRAME V2's syntax.
#
Use casesDeclaring a Storage Map and using it in a pallet.
#
OverviewWe will create 2 maps :
WhenLastSomethingDone
: to store the lastest block number when a function is calledCallsCounterBySender
: to store a counter by sender address for a function called
#
Steps#
1. Define a StorageMap instanceUse FRAME's StorageMap
to declare the struct as a new single item in storage:
WhenLastSomethingDone
storage item#
2. Write to the Example of using WhenLastSomethingDone
inside a function using insert
:
CallsCounterBySender
storage item#
3. Write to the Example of the CallsCounterBySender
StorageMap being used inside a function:
#
Examples- Inside FRAME's
pallet-balances
- StorageMaps in the
archipel project