Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Ethereum Projects for Beginners

You're reading from  Ethereum Projects for Beginners

Product type Book
Published in Jul 2018
Publisher Packt
ISBN-13 9781789537406
Pages 106 pages
Edition 1st Edition
Languages

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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}