Collections
Using stype variables in arrays and maps
All stype
variables can be stored in Solidity collections, much like their unshielded counterparts. They behave normally (as outlined in Basics) when used as values in these collections. It's when they're used as both the keys and values where it gets interesting. This applies to arrays and maps in particular:
What's special here is that you can hold on to a[idx]
and m[k]
without observers knowing which values in the collection they refer to. You can read from these references:
You can write to these references:
Observers for any of these operations will not know which elements were read from / written to.
In the previous section, we only knew how to shield what was happening for certain elements. Now, we know how to shield which elements are being modified in the first place.
We can take the ERC20 variant discussed in the Basics section and extend it further to shielded balances, transfer amounts, and now recipients.
Last updated