3

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.

2
  • You can not use arrays directly in multi_index. You should use a vector instead of an array.
    – smarteasy
    Commented Jun 21, 2018 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 Commented Sep 28, 2018 at 15:21

1 Answer 1

4

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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