Book Image

Ethereum Projects for Beginners

Book Image

Ethereum Projects for Beginners

Overview of this book

Ethereum enables the development of efficient, smart contracts that contain code. These smart contracts can interact with other smart contracts to make decisions, store data, and send Ether to others.Ethereum Projects for Beginners provides you with a clear introduction to creating cryptocurrencies, smart contracts, and decentralized applications. As you make your way through the book, you’ll get to grips with detailed step-by-step processes to build advanced Ethereum projects. Each project will teach you enough about Ethereum to be productive right away. You will learn how tokenization works, think in a decentralized way, and build blockchain-based distributed computing systems. Towards the end of the book, you will develop interesting Ethereum projects such as creating wallets and secure data sharing.By the end of this book, you will be able to tackle blockchain challenges by implementing end-to-end projects using the full power of the Ethereum blockchain.
Table of Contents (12 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributor
Preface
Index

Exploring the Solidity syntax and JavaScript codes


This section will help us understand the Solidity syntax. We will explore the Solidity and JavaScript codes to understand our project in depth. This will also give us the power to alter the code to customize it to our needs.

 

 

Understanding the Solidity syntax

For understanding the syntax, let's take a look at the Solidity file MetaCoin.sol. The following screenshot will act as a guide so that we understand every line of code:

As you can see, every Solidity file begins with the definition of the Solidity version that you are currently using. In this case, that would be 0.4.17. This is immediately followed by the importing of the conversion library (commonly known as ConvertLib.sol). This is shown the the code block as follows: 

pragma solidity ^0.4.17;

library ConvertLib{
    function convert(uint amount,uint conversionRate) public pure returns (uint convertedAmount)
    {
        return amount * conversionRate;
    }
}

We will now move on to...