Serializing string arrays in solidity

vasa
HackerNoon.com

--

TL;DR This GitHub repository is all you need.

Receive curated Web 3.0 content like this with a summary every day via WhatsApp, Telegram, Discord, or Email.

Solidity is still in development and that’s why it still lacks in a lot of features that a good programming language should have. One of the features which solidity is missing is that it cannot return or take multi-dimensional arrays as input. Well, that does not seem important but when we talk about strings, we realize that they are just arbitrary-length byte array(i.e. byte[]). So when you create a string array, you are creating a two-dimensional byte array(i.e. byte[][]). This is where we all get stuck. Kinda like a trap…

it’s a trap!

That’s enough of talking, let’s get to work. The easiest and the most efficient way to get over this problem is to serialize the strings in the array(converting the strings in the array into byte…

--

--

vasa
HackerNoon.com

Entrepreneur | Co-founder, TowardsBlockChain, an MIT CIC incubated startup | SimpleAsWater, YC 19 | Speaker | https://vaibhavsaini.com