COULD WE MAKE BYTES() IMPLICITLY MORE FLEXIBLE WITHOUT ADDITIONAL COMPLEXITY? #1118
Replies: 1 comment 2 replies
-
The first and second halves of your message are about very different things. For the first, the error
and not
For the second, Reach guarantees that your program will always be able to run. The only way it can do this is if it can determine how much state your program uses. If you run out of state, then the program will crash. For example, there is a limit to how many bytes can be given to a |
Beta Was this translation helpful? Give feedback.
-
Hello Reach Fam,
Could we make the
Bytes( )
Reach data structure more liberal in the strings it accepts? And if it is to be restricted because of storage costs, can it at least be explicit on the maximum? I am having trouble trying to define theBytes( )
data structure on my contract and then easily provide some random string on the frontend. The docs says I should use theData ( )
to substitute for it but it is hard to construct that because one way or another I will still have to defineBytes ( )
as a value to a variant. It just gets way more complicated than needed IMHO.Check this as an example:
I have a use case where I want users to publish assets that they have, so I create this:
The error I get is:
from my frontend interaction:
As you can see I assigned
assetName
toBytes(32)
, I am not allowed to have it open to sayBytes(WhateverSizeIsProvidedOnFrontend)
. The docs however is clear,and quote:
There is also the idea of padding, but if you are adding the padding process and check(assuring it does not go beyond or below size) e.g [https://github.com/reach-sh/reach-lang/blob/master/examples/dan-storage/index.rsh] to an old smart contract that holds your application's business logic then it makes your smart contract even more complex than needed, you get to debug new problems now.
I honestly think having some implicit functionality built into the
Bytes()
data type that is in some way liberal to the size of bytes, would really make life easier for Reach devs, especially myself and the use case I am working to deploy using Reach.I know one would think, why should there be freedom in making the Bytes() open, blockchains aren't built for storage after all, IMHO, for some applications, especially when you are doing something like NFTs, even the name of the NFT, though the name's size could be very long/short, still that name regardless of size will make the NFT or its computation(if we were hashing its details etc.) unique on-chain/off-chain, so we cannot risk the Byte size by making it rigid(i.e I have to explicitly define the byte length).
As you see in my use case, a plethora of names with different byte sizes for your asset can be provided e.g 'Real Estate', 'Cars', 'Tesla Stock', 'Mercedes-2769309v', 'Meaty-Borana-Cattle-From-MaasaiLand' etc. With the limited byte size, it limits the application's scope unnecessarily. At least another solution is also one could have an implicit maximum byte length below which they can provide any asset name, at least in this case the developer can work out policies to name, and trim those asset's names before they get to the Reach backend.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions