3

I'm looking at information about accessors in solidity/js for more complex data structures than just a public array/mapping.

How can i access the array in that code for:

struct AnotherStruct {....}
struct Example {
    uint example;
    uint[] exAmple;
    AnotherStruct[] strucs;
    mapping (uint  => AnotherStruct[]) structss;
  }
Example[] public examples;

From there i can do:

contractinstance.examples(index) in JS

It returns an array of one element ( as the Struct) value : 'uint example'

How can i access the data in the struct from the examples public array?

  • uint[] exAmple;
  • AnotherStruct[] strucs;
  • mapping (uint => AnotherStruct[]) structss;

I was expecting an array with like this : [uint example;uint[] exAmple,AnotherStruct[] strucs,mapping (uint => AnotherStruct[]) structss]

Where i could just have done array[3].iteration or array[4][uint] etc. but that doesn't seem to work that way.

Can anyone help?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.