Return an object next to an array when reading contract view #1315
Unanswered
deanpress
asked this question in
Idea / Feature Request
Replies: 1 comment 2 replies
-
Please see: https://viem.sh/docs/faq.html#why-is-a-contract-function-return-type-returning-an-array-instead-of-an-object The second example you provided is not serializable in JavaScript. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, if you read a contract with multiple return values or a struct, you just get an array. It'd be great if, next to an array, you can also get values by their attributes as defined in the abi.
For example:
The latter is backwards compatible (same way as ethers returns contract return values) and allows you to query values by their key name, rather than having to refer to the abi every time to ensure you get the right key number.
Edit:
To keep it serializable in Javascript you could have it like this:
Beta Was this translation helpful? Give feedback.
All reactions