1

I want users to be able to store long URLs on Etherum.

 mapping(address => string[]) public addressToLinks;

UnimplementedFeatureError: Accessors for mapping with dynamically-sized keys not yet implemented.

I cant seem to use strings, and there doesn't seem to be a data type for larger bytes, like bytes256.

What is the best way to solve this problem? I'm not opposed to using the new experimental ABI encoder, but I still cant figure out a good solution... (I dont want to use a URL shortener)

I suppose I can store a mapping to a uint index, and have the index take me to a giant 2d array of arrays of strings... but theres gota be a better way....

Thanks!

1 Answer 1

3

The compilation error is due to the fact that a getter function for mapping(any_type => string[]) is not yet supported, so you cannot declare such mapping as public.

By the way, this is true not only for string[], but also for string.

So change this:

mapping(address => string[]) public addressToLinks;

To this:

mapping(address => string[]) private addressToLinks;

Or to this:

mapping(address => string[]) internal addressToLinks;

And add this:

function getLink(address key, uint index) external view returns (string) {
    return addressToLinks[key][index];
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.