I'm working on a Substrate project, and I have the following storage definition:

#[pallet::getter(fn bids)]
pub(super) type Bids<T: Config> = StorageDoubleMap<
    (Key<T>, BalanceOf<T>),

I'm trying to retrieve all items associated with a specific auction key using the Bids storage. Here's the code I'm using:

let auction_key: Key<T> = ...; // Set the auction key appropriately

let bid_history: = Bids::<T>::get(&auction_key);

This function takes 2 arguments but 1 argument was supplied

It seems that the get function of Bids requires two arguments instead of one. I'm looking for a way to retrieve all items related to the auction_key. How can I modify my code to achieve this?

1 Answer 1


You have to use iter_prefix_values (see Rust Docs), to iterates over values that share the first key.

See an example in this test in the FRAME support pallet:

type A = StorageDoubleMap<Prefix, Blake2_128Concat, u16, Twox64Concat, u8, u32, OptionQuery>;
A::insert(3, 30, 11);
A::insert(3, 31, 12);

assert_eq!(A::iter_prefix_values(3).collect::<Vec<_>>(), vec![12, 11]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.