Array/mapping support for Pyteal

Hi, am looking to create a growing list of records. We have some records we’ll store on IPFS and we want to store the hash on contract. There would be new hash everyday and an array is required to store it. These are not created by users so we can’t store it on local storage. As I understand there can only be 64 key-value pairs each with 64 byte max size. New to Algorand, correct me if I have made any wrong assumptions. Thanks in advance!

Yes, and each value is at most 64 bytes, so if you use SHA256, you can store 2*64 hashes.

How do you plan to use these values?
Does a smart contract need to act upon them?
If not, you can just store the hash as notes in transaction, and do not need any smart contract (see Algorand Developer Portal)
If you do need to use a smart contract and do need to store more values, one solution is to use a Merkle Tree.

Hi Fabrice,

Following this topic. I have a similar situation when I need to save/update some lists in global and local storage of smart contract. Merkle Tree isn’t helpful as I need to get data also. So not only verify, but read the content. Is there any new solution in Algorand regarding this?

The Merkle tree solution indeed requires you to store the hashes somewhere else. It would work if every time you need to read the data, you can provide the path to the leaf in the Merkle tree.

If this is not possible, another option is to store data as local state in accounts that opt in to your smart contract. These accounts may be (stateless) smart contract accounts that only allow opt in to your smart contract. Then your smart contract can read any of those local state using the foreign account feature:

New versions of smart contract may provide additional solutions in the future:

1 Like