So. I started using too many mappings. Now I'm not sure how to get the information on the front:

struct Demand{
    uint remuneration;
    uint delay;
    uint deadline;
    string description;
    Status status;
    uint minRep;
    mapping(address => bool) candidates;
    address payable chosen;
    address addressCompany;
    uint deposit;
    string art_piece;
    bool url_exist;
    mapping(address => uint) balances;
    uint value;

struct Companies{
    string name;
    mapping(string => Demand) demands;
    mapping(string => bool) all_demands_company;


mapping(address => Companies)  public companies;

I tried to access the structure of demands by adding the following:

string[] all_demands;
address[] public companies_addresses;

Then in react I try to get Demand structure by making an array that looks like this:

Array = [[company1, demand1],[company1, demand2], [company2, demand1], ...]

The issue then is that I have no idea how to access Demands like this. I thought there was a free getter provided when doing public mappings. But it doesn't work.

Should I drop it all and work with arrays instead of mappings?

  • 1
    Your question is unclear. Please show code instead of saying "I tried", i.e., how exactly did you try? Those two arrays that you added in your contract are empty, why do you expect to get any data from them??? I have no idea how to access Demands - What is "Demands"??? There are 4 occurrences of this word in some variation in your code, but none of them is identical to Demands! – goodvibration May 18 at 4:16

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.