I have a smart contract action that needs to be able to take in an array of values as one of its parameters. This array is of arbitrary length. What is the proper method signature to use for the method?

I've tried void container::add(account_name user, uint128_t ancestorIDs[]) this, with the corresponding ABI entry {"name": "ancestorIDs", "type": "uint128[]"}, but I encounter compile errors when I attempt to use the parameter.

  • You can not use arrays directly in multi_index. You should use a vector instead of an array. – smarteasy Jun 21 '18 at 1:28
  • vector does not help as well, it creates a "type: "string>" in the abi and nodeos says Error 3015004: The type defined in the ABI is invalid – Lonkly Sep 28 '18 at 15:21

After looking through the example contracts, I finally found one that had an array of objects. To receive them, the contract needs to declare the parameter as a std::vector<uint128>. The multi_index table structure can store them by declaring the corresponding field in the structure in the same way.

This is best shown by the identity contract's certprop function.


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.