Support for strings of indeterminate length

I was thinking of working on contract that involves doing hashes on pretty long strings (at any rate usually >31 bytes), and also putting the strings in storage. I’m new to programming blockchain stuff, but have learnt enough solidity to get something fully functional & have tested on both Eth Mainnet & Arbitrum. It would be interesting to get it working / testing on Starknet though.

As I understand it, Solidity internally converts long strings to dynamic arrays of 32 bytes and back again, simply chaining them together. My question for Cairo is – is this something that should be / is likely to be a feature of the language (short string conversion for <32 bytes is already implemented) – or is it in theory something that could be / should be written in Cairo? It strikes me as “non-trivial” but extremely useful. I also imagine a lot of what they did in Solidity could be repurposed here, since it’s a similar setup internally? Could anyone point me in the way of how it might be done, or is it just better to wait until support for this in the language is available, or use Warp when that’s ready and working?

3 Likes

Hello !

This is indeed a big area of improvement. Supporting different data types is on our feature list (specificaly uint256 and strings).
For now though, you can use Cairo code to do the trick.

This contract for example has some nice functionnalities to read / store / write strings in cairo

1 Like

Hello. Yes, native support for Strings would make life much easier. Especially to conform to ERC standards implemented by OpenZeppelin, Oasis and others.

Do you have a roadmap milestone or a date when you plan to release this?

Thanks!

1 Like