Skip to Content
Building Blockchain Projects
book

Building Blockchain Projects

by Narayan Prusty
April 2017
Intermediate to advanced
266 pages
7h 4m
English
Packt Publishing
Content preview from Building Blockchain Projects

Strings

In Solidity, there are two ways to create strings: using bytes and string. bytes is used to create a raw string, whereas string is used to create a UTF-8 string. The length of string is always dynamic.

Here is an example that shows string syntaxes:

contract sample{     //wherever a string literal is seen a new string is created. If the string literal is in state than it's stored in storage and if it's found inside function than its stored in memory     //Here myString stores "" string.      string myString = "";  //string literal     bytes myRawString;     function sample(string initString, bytes rawStringInit){         myString = initString;         //myString2 holds a pointer to myString         string myString2 = myString;         //myString3 is a string in memory   string ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Building Blockchain Apps

Building Blockchain Apps

Michael Juntao Yuan
Blockchain Development with Hyperledger

Blockchain Development with Hyperledger

Salman A. Baset, Luc Desrosiers, Nitin Gaur, Petr Novotny
Advanced Blockchain Development

Advanced Blockchain Development

Imran Bashir, Narayan Prusty

Publisher Resources

ISBN: 9781787122147Supplemental Content