Let's say I wanted to store an entire article or a manifest on the Tezos blockchain. Something that is bigger than 100kB. How would I go about doing that?
-
I am well aware that you for any useful app would store hashes of data/strings, and big amounts of data do not belong on any public blockchain. This is however, a one-time project that is made for aesthetical reasons, not to create a well-functioning app. Hence the question.– Thorkil VærgeSep 4, 2020 at 14:38
-
You should provide more details in order to receive a proper technical answer, though there is general agreement it is not a best practice to put all this data on the blockchain. In particular, do you mean at contract origination (not possible), do you mean for contract to read it on invocation (not possible), how do you want to access it later– cousinitSep 4, 2020 at 18:36
2 Answers
You actually answered the question in the comments, but for those who don't read comments:
There are two limitations:
max_operation_data_length
:16384
byteshard_storage_limit_per_operation
:60000
bytes
This means that you can't send more than ~16KB per transaction, so the only way is to split the "really long string" into chunks and store those chunks in lazy storage (bigmap).
Or, as @FFF mentioned, you might want to store large data somwhere else and store its hash(+link) in the blockchain
-
Thank you for the clear answer. This is excellent. So the data structure would be
big_map(nat, string)
, where eachstring
can maximum be around 16kB. Reading from this storage could then be done by trying the keys 0 to N, until the empty result was returned. Sep 7, 2020 at 11:17
You shouldn't do it. It's very expensive and a total waste of resources.
What you can definitely do is store a hash of your string or a ipfs address for example (which is more or less the same).
-
Thanks for your considerations but you are not answering my question. Your consideration is better suited as a comment than an answer. Sep 4, 2020 at 13:20
-
That being said, for any serious/useful app, I fully and wholeheartedly agree with you. But this is something different, where aesthetics is the main purpose ... Sep 4, 2020 at 13:45
-
I agree with the answer, with a string of this size, the gas storage limit would be exceeded very quickly. You can find more information here => tezos.stackexchange.com/questions/2183/… Sep 4, 2020 at 14:00
-
Then I can store the big string through multiple operations, and store each part of the string in a
big_map
, adding 16kB or 60kB in each transaction. Sep 4, 2020 at 14:05 -
1I've just tried on KT1M4hGQa7YdYBi7ovBkoWVouHGPtDKR7r9b on Delphinet, a contract that doubles its string several times and we get a storage exhausted operation. You can see block BMNwN31Rggxy8aHsMgk7kekcV7KRDNdK7p5EyyRopGvRpsHucop on smartpy.io/… with delphinet.smartpy.io. The big map would work.– FFFSep 4, 2020 at 16:37