Solidity – Is it Possible to Have a Mapping to a Tuple?

mappingsolidity

Is it possible to have a mapping where the values are a tuple?

mapping (address => (bool, uint)) participants;

Best Answer

If you use a struct, eg

struct Participant {
    bool value1;
    uint value2;
}

mapping (address => Participant) participants;

I don't think there's any way of using an actual Tuple eg var (a, b) in a mapping since the types of a and b cannot be declared with the syntax available. With a struct the types can be declared, which is necessary to declare the mapping type.