Can i do reverse mapping in solidity language.
case 1 :
mapping(address=>uint256) ----- mapping
mapping(uint256=>address) ------reverse mapping
can we perform case 2 in solidity successfully?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
mapping(uint256=>address) is valid.
Mapping types are declared as mapping(_KeyType => _ValueType). Here _KeyType can be almost any type except for a mapping, a dynamically sized array, a contract, an enum and a struct. _ValueType can actually be any type, including mappings.
But, if the value of the first mapping is a mapping or struct, then a reverse mapping would not be possible.
See the source (Solidity docs) for more information.