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?

  • the issue seems to be with requiring the vector to be a fixed size – nakomis Mar 8 '19 at 1:53
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.

Your Answer

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

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