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

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

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

How to handle dynamic size string array in solidity?

Updated November 28, 2018 04:28 AM

Circular reference error in factory contract pattern

Updated January 26, 2019 18:28 PM

How can I pass struct from one contract to another?

Updated January 10, 2019 23:28 PM