1

I declare a vector vector<string> data inside a contract.

Contract Code:

book.emplace(_self, [&](struct wname &a){
                a.name = fa.pubaddress;
                a.namehash = nameHash;
                a.domain = fa.domain;
                a.domainhash = domainHash;
                a.expiration = expiration_time;
                a.data[0] = fa.data;
            });

ABI FILE:

,{
          "name": "data",
          "type": "string[]"
        }

When I use the get table inside cleos I get this information:

{
  "rows": [{
      "name": "adam.com",
      "namehash": "649317735385268224",
      "domain": "com",
      "domainhash": "1479432477591207936",
      "expiration": 1583565049,
      "data": []
    },{
      "name": "casey.com",
      "namehash": "1758194651256324096",
      "domain": "com",
      "domainhash": "1479432477591207936",
      "expiration": 1583565049,
      "data": []
    }
  ],
  "more": false
}

Why does the vector of data not display?

1
  • the issue seems to be with requiring the vector to be a fixed size
    – nakomis
    Mar 8, 2019 at 1:53

1 Answer 1

2

You need to push back values into the vector like this:

book.emplace(_self, [&](struct wname &a){
                a.name = fa.pubaddress;
                a.namehash = nameHash;
                a.domain = fa.domain;
                a.domainhash = domainHash;
                a.expiration = expiration_time;
                a.data.push_back(fa.data);
            });

I don't know what fa is here but. But if fa.data contains a string value it will work now.

2
  • @nakomis: Did this solution work for you?
    – Rahul Malu
    Mar 13, 2019 at 7:45
  • @RahulMalu do you have similar issue? Mar 14, 2019 at 6:26

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.