I've learnt that i can easily read into a struct array by default getter like :

contract bisounoursCity {

  struct Person {
    uint8 age;
    string name;
    string hairColor;

  Person[1000] public people;


i can read a single person with web3 :




Thats great ! But what if i want to get ALL people of my city ? You see that 1000 people are here and i don't want to make 1000 call function. It will be so better to just get the entire array and then play with this data !

But i don't know how to get simply an entire array, because a wonderfully function like

function getCity() public view returns(Person[1000]) {
   return people;

makes my compiler a little bit irritated :

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

So i tried like :

function getCity() public view returns(uint8[1000],  string[1000], string[1000]){
// filling with the properties

But the same error happen (returning a string array causes the problem...).

Do you know a way to get my wonderful city ?

Many thanks,

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.