How it works...

EVM is the runtime environment for Ethereum smart contracts. Contracts running inside EVM have no access to the network, filesystem, or other processes. This is because of the isolated and sandboxed nature of EVM.

The first line in this smart contract tells us that the source code is written for compiler version 0.4.21 or anything newer (such as <0.5.0) that does not break any functionality. The pragma keyword is used because pragmas are instructions for the compiler about how to treat the source code. 

The line string textToPrint = "hello world"; declares a state variable called textToPrint and assigns a value to it. You can think of it as a slot in a database that can be queried and altered by calling the functions in the code that manage the database. To access the variable inside the contract, you don't need to use this as in other languages.

This is a simple contract that allows anyone to store a string that is accessible by anyone in the world, without a way to prevent you from publishing this value. Anyone could just use a different value and overwrite your string, but the old string will still be stored in the history of the blockchain. You will learn to restrict write access to a contract in a different recipe.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.15.161