I am working on a pallet in which there is storage in which I am using a tuple. Can we use a struct instead of a tuple in the storage of pallet? if yes is there any reference to how we can use it?

1 Answer 1


If you use FRAME and the corresponding macros to define storage, then in that case the values stored will be serialized using the SCALE encoding.

SCALE encoding is equivalent between structs and tuples as long as they have the equal number of fields, with the same types.

For example, those structs

type A = (u32, bool);

#[derive(Encode, Decode)]
struct B {
  number: u32,
  flag: bool,

should be encoded the same way, so the following assertion will always be held:

// for each a of type A and each b of type B
fn test(a: A, b: B) {
  // the SCALE encoding will be equal

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.