Keys
Create a type that will be used to query the counter state.
Also create a function to construct this type from the ABI.
Key
s are vectors of words so here we create a vector with a single word.
#![allow(unused)] fn main() { #[derive(Clone)] pub struct CounterKey(pub Vec<Word>); pub fn counter_key() -> CounterKey { let keys: Vec<_> = storage::keys().counter().into(); CounterKey(keys.first().unwrap().clone()) } }
Here, we're extract the storage key for the storage variable counter
by using the method
counter()
.