You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello @swswsw
Thanks for the question.
Unfortunately it is impossible to directly return all the elements in a mapping or even in a array using solidity.
A possible workaround would be keeping an array to track all the addresses that have been populated inside the mapping, and then iterating through the array to get all elements.
It could be possible to implement a library called "extended mapping", consisting of a mapping with extended methods such as python's .items(), .keys(), .values()...
Yes, it would. The problem is that those constructions spend huge amounts of space to map it all out. It is advisable to, whenever possible, do all of these operations offchain, and include onchain only the inevitable.
for example:
It is easy to get Item based given user address. What if we want to get all user address? Or if we want to get all the items?
The text was updated successfully, but these errors were encountered: