How to map an address with a string array in solidity?

by Gagan   Last Updated October 09, 2018 12:28 PM

Goal: I wish to store an array of names with an address in a smart contract. It's more like Key-Value pairs where addresses are paired with a list of type strings.

Can I use mapping to implement this? See below for instance.

mapping(address => strings[]) userAddress2UserNames;

Or, there is a different approach to it?

Experiments I performed

I got no error when I compiled the above code but when I call a method which returns string[] from this mapping I got an error stated below.

TypeError: This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.

I'm not much aware of this version but I am assuming I should not do production level implementation with it because may be it's not stable. (Please correct me if I am wrong)

Please suggest me a way to achieve my goal.



Related Questions


Updated November 28, 2018 04:28 AM

Updated January 26, 2019 18:28 PM

Updated January 31, 2019 07:28 AM

Updated July 20, 2018 04:28 AM

Updated January 10, 2019 23:28 PM