Ethereum For Dummies book cover

Ethereum For Dummies

Author:
Michael G. Solomon
Published: April 23, 2019

Overview

Dive into a secure future

Professionals look to Ethereum as a blockchain-based platform to develop safe applications and conduct secure transactions. It takes a knowledgeable guiding hand to understand how Ethereum works and what it does — and Ethereum For Dummies provides that guidance. Written by one of the leading voices in the blockchain community and best selling author of Blockchain For Dummies, this book demystifies the workings of Ethereum and shows how it can enhance security, transactions, and investments. 

As an emerging application of blockchain technology, Ethereum attracts a wide swath of professionals ranging from financial pros who see it as a way to enhance their business, security analysts who want to conduct secure transactions, programmers who build apps that employ the Ethereum blockchain, or investors interested in cashing in on the rise of cryptocurrency. Ethereum For Dummies offers a starting point to all members of this audience as it provides easy-to-understand explanation of the tools and techniques of using Ethereum.

  • Understand the fundamentals of Ethereum
  • Build smart contracts
  • Create decentralized applications
  • Examine public and private chains 

If you need to get a grip on one of the biggest applications of blockchain technology, this book makes it easier.

Dive into a secure future

Professionals look to Ethereum as a blockchain-based platform to develop safe applications and conduct secure transactions. It takes a knowledgeable guiding hand to understand how Ethereum works and what it does — and Ethereum For Dummies provides that guidance. Written by one of the leading voices in the blockchain community and best selling author of Blockchain For Dummies, this book demystifies the workings of Ethereum and shows how it can enhance security, transactions, and investments. 

As an emerging application of blockchain technology, Ethereum attracts a wide swath of professionals ranging from financial pros who see it

as a way to enhance their business, security analysts who want to conduct secure transactions, programmers who build apps that employ the Ethereum blockchain, or investors interested in cashing in on the rise of cryptocurrency. Ethereum For Dummies offers a starting point to all members of this audience as it provides easy-to-understand explanation of the tools and techniques of using Ethereum.

  • Understand the fundamentals of Ethereum
  • Build smart contracts
  • Create decentralized applications
  • Examine public and private chains 

If you need to get a grip on one of the biggest applications of blockchain technology, this book makes it easier.

Ethereum For Dummies Cheat Sheet

Ethereum is much more than just another blockchain implementation. It is a complete dApp (decentralized app) development and runtime environment. To best leverage all that Ethereum offers, become familiar with what blockchain technology can do for you and the extras that Ethereum offers. Learn the main language of smart contracts, Solidity, and how you can use its syntax to make your dApps provide value to its users. And establish a healthy respect for each of the steps in the Ethereum dApp development process so you will have more effective software.

Articles From The Book

10 results

Cryptocurrency Articles

Basic Ethereum Smart Contract Syntax

If you plan to do any Ethereum development, you’ll likely be using Solidity, one of the most popular programming languages for smart contracts. Let’s take a look at some basic Solidity syntax. When you write Solidity source code, you save that code in a file with the extension .sol. A Solidity program has several main sections, as follows:

  • Pragma: This tells Solidity what versions of the compiler are valid to compile this file.
  • Comments: Developers should use comments for documenting code.
  • Import: An import defines an external file that contains code that your smart contract needs.
  • Contract(s): This section is where the body of your smart contract code resides.

Declaring valid compiler version in Ethereum smart contracts

The pragma directive should be the first line of code in a Solidity file. Because the Solidity language is still maturing, it is common for new compiler versions to include changes that would fail to compile older programs. The pragma directive helps avoid compiler failures due to using a newer compiler. Here is the syntax for the pragma directive:
pragma Solidity <>;
Here is a sample pragma directive:
pragma Solidity ^0.4.24;

All statements in Solidity end with a semicolon.

The version number starts with a 0, followed by a major build number and a minor build number. For example, the version number 0.4.24 refers to major build 4 and minor build 24. The caret symbol (^) before the version number tells Solidity that it can use the latest build in a major version range. In the preceding example, Solidity can use a compiler from any build in the version 4 build range. This is a way to tell readers that your program was written for 0.4.24 but will still compile for subsequent version 4 builds. Although using the caret in the pragma directive provides flexibility, it is a better practice to drop the caret and tell Solidity exactly what compiler version you expect.

Commenting your Solidity code

Adding comments to your code is an extra step that adds a professional look and feel to your Solidity code. A well-commented source code file is easier to read and understand and helps other developers quickly understand what your code is supposed to do. Even simple comments can cut down on the time required to fix bugs or add new functionality. Comments can also provide input for utilities to generate documentation for your smart contracts. You can use single-line or multiline regular comments. Single-line comments start with two forward slashes. Multiline comments start with the /* characters and end with the */ characters. Here is an example of Solidity comments:
// Here is a single line Solidity comment
/* I have a lot more to say with this comment, so I’ll
use a multiline comment. The compiler will ignore
everything after the opening comment characters, until
it sees the closing comment characters. */
A third type of Solidity comment is called the Ethereum Natural Specification (NatSpec) directive. You can use NatSpec to provide information about your code for documentation generators to use to create formatted documentation the describes your smart contracts. NatSpec directives start with three forward slashes and include special tags with data for the documentation. Here is an example of using NatSpec directives:
/// @title Greeter smart contract
/// @author Joe Programmer
/// @notice This code takes a person's name and says hello
/// @param name The name of the caller
/// @return greeting The greeting with the caller's name

Check out NatSpec documentation for additional information.

Importing external code into your Ethereum smart contract

The import section is optional but can be powerful when used correctly in your Ethereum smart contract. If your smart contract needs to refer to code in other files, you’ll have to import those other files first. Importing files makes it as though you copied the other code into the current file. Using imports helps you avoid actually copying code from one place to another. If you need to access code, just import the Solidity file that contains it. The syntax for importing other files is simple. You use the import keyword and then provide the filename for the file you want to import. For example, to import the file myToken.sol, use this syntax:
Import 'myToken.sol';

Defining your Ethereum smart contracts

In the last main section of Solidity, you define the contents of your smart contract. It starts with the keyword contract and contains all of the functional code in your smart contract. You can have multiple contract sections in Solidity. That means a single .sol file can define multiple contracts. Here is an example contract section:
contract HelloWorld {
string private helloMessage = "Hello world";
function getHelloMessage() public view returns (string) {
return helloMessage;
}
}
Inside the contract section is where you define all of your variables, structures, events, and functions. There's a lot more to the contract section of your code, but for now, you know how to set up a Solidity smart contract. Once you master the basics of Solidity, you can continue to develop more complex code and the sky's the limit.

Cryptocurrency Articles

Top 10 Ethereum Uses

Blockchain technology in general, and Ethereum in particular, is rapidly growing in popularity. Increasing numbers of organizations are embracing Ethereum for new projects. The variety of projects that use Ethereum as their foundation is almost limitless. A quick look at the State of the dApps website shows how many Ethereum projects exist in different categories and how popular they are. This resource is a great way to stay current on trending dApps. Although these Ethereum projects are just a small representative sample of what is out there, they will give you some exposure to what others are doing with Ethereum. Perhaps you’ll find some ideas for new and exciting ways that Ethereum can help transform your organization. Though these projects are very different, they are all built on Ethereum. Each project uses smart contracts running on the EVM to carry out functionality and the Ethereum blockchain to store state data.

Gnosis predicts future events with Ethereum

Gnosis is one of the many innovative companies using Ethereum in interesting ways. Gnosis provides a platform for prediction markets. The Gnosis Olympia product is the alpha version of their platform. Using Olympia, participants get an initial balance of OLY tokens, pretend money they can use in Olympia, which they use to make predictions on a variety of topics. Participants can win GNO tokens for making successful predictions. Participants who set up predictions associate the prediction with an oracle for outcome validation. For example, the true value of a specific stock price at a specific date and time is easily validated by comparing the prediction with published stock prices. The stock price data source would be the oracle that the stock price prediction uses for validation. Gnosis Olympia provides the platform for participants to determine the probability of a given outcome. You can use Olympia to determine an expected value of some item of value. Knowing an item’s value gives you more leverage in negotiations. Another possible use is elections. Distributed prediction markets could emerge to provide better forecasts of upcoming elections. Political polling is often criticized for imprecision, and emerging products could make it more accurate.

Augur crowdsources event predictions

Augur is another offering in the prediction market category. As they do using Gnosis, participants can record events and then provide a prediction on the outcome of the event. Augur rewards participants with REP tokens in exchange for providing accurate data related to the event and for voting with the majority. Augur is based on crowdsourced data and gets more accurate with the inclusion of participant data. That’s why submitting accurate data earns rewards. An oracle validates event data and outcome, but the emphasis is still on crowdsourced input. Augur is completely decentralized and depends on smart contracts and the Ethereum blockchain to operate. Its goal is to provide a global portal that generates better forecasts about the outcome of any future event that enjoys widespread global interest.

Aragon manages decentralized organizations with Ethereum

Aragon is a platform dedicated to helping manage decentralized organizations, which often suffer from a lack of infrastructure and functionality. Aragon participants buy Aragon Network Tokens from one of several popular cryptocurrency exchanges and use ANT to pay for Aragon services. Aragon facilitates distributed autonomous organization governance, fundraising, and accounting. For example, Aragon participants can pose questions to their organization for voting. The Aragon environment handles all of the details of managing the voting process, resulting in verified election outcomes. Voting is just one of the features of the platform. The Aragon project has as its goals to empower decentralized organization participants by promoting participation and providing financial transparency. Aragon enables organizations to exist outside the traditional hierarchical, centralized model.

Breed and collect cryptokitties in Ethereum

Ethereum isn’t just about cryptocurrency and business function. You can find some fun games in the Ethereum space. too. Cryptokitties, one of the first Ethereum-based games, is still popular. This revolutionary game introduced blockchain-based cryptocollectibles. That’s right. Cryptokitties are collectible. Each cryptokitty is unique. Technically, each cryptokitty is an ERC-721 token and has a unique set of cattributes (cryptokitty DNA) that come from each cryptokitty’s parents. You don’t create cryptokitties; you breed them. And just as in real life (well, kind of), you can either trust genetic luck to create a rare and valuable cryptokitty, or you can pay a siring fee to another cryptokitty for the capability to breed using their cryptokitties. Each cryptokitty has a different value, based on the rarity of its cattributes. In the past, some cryptokitties with rare cattributes (and a favorable ETH exchange rate) sold for more than $100,000 USD. The image below shows the Cryptokitties website with examples of a few cryptokitties, each with its own unique cattributes.

Exchange tokens with IDEX

Thousands of ERC-20 tokens are in use. Before you can use a token to pay for something, you have to acquire it. Some tokens are free, but others must be purchased. To buy a token, you must exchange currency or cryptocurrency, so you need an organization that provides exchange services. IDEX is a decentralized exchange that specializes in trading between ETH and ERC-20 tokens. It confirms transactions in its smart contract, without waiting for Ethereum block mining. IDEX’s capability to confirm transactions in real time allows traders to trade continuously. Orders are recorded on the Ethereum blockchain in the order in which they were received, but traders don’t have to wait for their tokens. They receive them as soon as their order is approved by the smart contract. This image shows the IDEX website with a list of the most active Ethereum ERC-20 tokens.

Use Ethereum to create your digital identity with uPort

The uPort dApp is an innovative initiative with a simple purpose: to provide a decentralized identity for everyone, stored on the Ethereum blockchain. A user registers their identity through uPort. Once authenticated, users can use the uPort digital identity to sign digital contracts and interact with other services that require validated identities. The uPort dApp has scores of potential uses. One of the most visible needs uPort could help address is in providing people who have lost physical identification items to still provide proof of identity when required. Survivors of catastrophic events often have no identification. Accessing an immutable digital identification could help. Digital identities could help with immigration, voting, and other cases where identification is required.

Share your thoughts on the blockchain with EtherTweet

As its name suggests, EtherTweet is a blockchain alternative to Twitter. The main difference is that EtherTweet is censorship-free because all messages are stored on the Ethereum blockchain. You can post up to 160 characters. Although prices change based on the current value of ether, creating an EtherTweet account costs about 2 cents and each tweet costs about one third of a cent. The following image shows the EtherTweet website with instructions on using their web interface to post and read tweets.

Use Ethereum to search for Jobs with EthLance

EthLance is a distributed platform for freelancers and employers to find each other, engage in jobs, and transfer payment in ether. EthLance is part of the district0x network, which is a collective of decentralized marketplaces and communities. One of EthLance’s outstanding features is that it does not collect any fees. Membership in EthLance is free, and both freelancers and employers can use the network to match personnel with open jobs. Once work is complete, employers can pay freelancers directly using ether. The entire EthLance platform runs in Ethereum. The transparent nature of EthLance and its zero fees model make it a great resource for self-employed individuals. The image below shows the EthLance website with their “how it works” graphic showing how freelancers and employers can use the services.

Using TenX to pay with ether and other cryptocurrencies

TenX allows customers to use ether and other cryptocurrencies at retailers to pay for purchases around the world. Although most retailers don’t directly support cryptocurrencies yet, TenX created their own line of crypto debit cards and credit cards that link up with its proprietary crypto wallet. The TenX cards provide the bridge between cryptocurrencies and traditional payment vehicles. TenX records all payment transactions on the blockchain and has plans for a larger network that will allow apps to communicate across multiple blockchains. The image below shows the TenX website with an image of their TenX debit card.

Use Ethereum to buy and sell computing power with Golem

The last innovative Ethereum project is Golem. Golem is a decentralized marketplace for buying and selling computing power. Whether you have excess computing power you’d like to sell, or you need to temporarily rent more computing power to complete a project, Golem can help. You can use Golem supercomputers after paying in native GNT token, or you can earn GNT by letting others use your excess computing power. Ethereum can be used for all sorts of creative projects. How will your organization use Ethereum?

Cryptocurrency Articles

What is Ethereum?

Ethereum is a comprehensive, decentralized application platform that expands the range of capabilities beyond what was possible before blockchain technology. So, what sets it apart from other decentralized platforms? Here’s a bit of Ethereum background.

Introducing Ethereum

Bitcoin was the first blockchain technology application. It was revolutionary and defined the first widely used digital currency, called cryptocurrency. The crypto part of the name refers to the use of cryptographic hashes to ensure the integrity of the blockchain. The shared ledger literally keeps a copy of every cryptocurrency transaction that gets verified by all nodes. Using this approach, bitcoin created a permanent record of every exchange of their cryptocurrency. And, because account owners are identified only by an address, bitcoin has always enjoyed a measure of anonymity.

Although bitcoin addresses aren’t linked directly to people, many exchanges have records of identities that are related to addresses. At some point, you have to exchange your cryptocurrency for real currency. That switchover point is where many law enforcement officials focus when they’re trying to track down criminals using cryptocurrency.

As bitcoin became more and more popular, researchers began to see more applications for blockchain technology beyond cryptocurrency. In 2013, Vitalik Buterin, the cofounder of Bitcoin Magazine, published a whitepaper that proposed a new, more functional blockchain implementation. This new proposal was for the Ethereum blockchain. After gaining interest and attracting technical and financial support, the Ethereum Foundation, a Swiss non-profit organization, was founded and became the developer of Ethereum. Ethereum wasn’t created just to exchange cryptocurrency. In fact, it was designed from the beginning to be different. The core features of Ethereum are the smart contract and ether. Ether is the native cryptocurrency that Ethereum supports, although you can create your own tokens to exchange value in many other forms. Smart contracts provide an execution environment that ensures integrity across all nodes. Any code that executes on one node executes the same way on all nodes. This guarantee makes it possible to deploy a wide range of applications across untrusted environments. The foundational guarantees Ethereum provides support many types of value exchanges without the concern about fraud, censorship, or any involvement by a third party. When you interact with an Ethereum application, you don’t have to rely on any intermediary to broker your transactions. You don’t need a bank, wholesaler, or transaction broker to provide trust. As a result of Ethereum’s disintermediation, you can often complete transactions faster, with far lower service fees and without requiring approval from external authorities. Whereas legacy solutions to data and process sharing required third-party authorities to enforce integrity, Ethereum provides process and data integrity, along with disintermediation. The possibilities are just beginning to be explored.

Exploring Ethereum’s consensus, mining, and smart contracts

Ethereum provides integrity in the way it implements immutability and smart contracts. Immutability isn’t actually a blockchain guarantee. You can change data in any block — even after other blocks are added to the blockchain. However, as soon as you change a block, that block and all subsequent blocks fail integrity checks and your node is out of sync. Instead of saying that the blockchain is immutable, it is more accurate to say that any changes (mutations) to the blockchain are easily and immediately detected.

Ethereum is based on democracy. Each node gets an equal vote. Every time nodes get a new block to add to the blockchain, they validate the block and its transactions, and then vote whether to accept or reject the block. If several different blocks are submitted by different nodes, only one of the blocks can receive votes from a majority. The block that gets more than half of the network node’s votes gets to join the blockchain as its newest block.

One of the first problems is to determine when a new block is ready for the blockchain. When too many conflicting blocks are submitted, the voting process slows down. Ethereum makes it hard to add new blocks to keep the number of new block collisions low and to make voting faster. Ethereum uses a consensus protocol called Proof of Work (PoW), which sets the rules for validating and adding new blocks. PoW makes add blocks to the blockchain difficult but profitable. Ethereum defines ether as its cryptocurrency. You can transfer ether between accounts or earn it by doing the hard work of adding blocks to the Ethereum blockchain. The Ethereum PoW mechanism requires that nodes find a number that, when combined with the block’s header data, produces a cryptographic hash value that matches the current target, which is a value that is adjusted to keep new block production at a steady rate. Finding a hash value that matches the current target is hard. You have to try on average more than a quadrillion values to find the right one. That’s the point. Using a PoW mechanism makes it so hard to submit a block that fewer blocks are submitted, which reduces the number of collisions. The node that finds the right value gets a small ether payment for the effort. This process is called mining, and the node that wins the prize is that block’s miner. Mining regulates the speed at which new blocks get submitted as candidate blocks, and results in a number that is easy to validate. Finding the right number to solve the puzzle is difficult, but verifying the number is fast and easy. Another interesting aspect of mining is that each block’s header contains a hash from the previous block. Ethereum nodes use the hash to easily detect unauthorized block changes. If a block changes, the hash result doesn’t match and the block becomes invalid. Mining cryptocurrency is also a way to make money using blockchain technology. Mining has become competitive, and most of today’s miners invest in high-performance hardware with multiple GPUs to carry out the complex operations. To keep the mining process fair, Ethereum uses a complexity value that makes the mining process even harder as miners get faster. Adjusting the complexity allows Ethereum to regulate the new block frequency to an average of one new block every 14 seconds.

The glue that holds the Ethereum environment together is the smart contract. Ethereum is much more than just a financial ledger, and smart contracts provide much of its rich functionality. Each Ethereum node runs a copy of the Ethereum virtual machine (EVM).

The EVM runs smart contract code in a way that guarantees that smart contracts execute the same way on all nodes and produce the same output. Running smart contract code is not optional. Smart contracts execute based on specific rules and cannot be subverted or halted. The EVM smart contract guarantees provide a stable platform for automated transaction processing that you can trust. Smart contracts provide the primary power of the Ethereum environment. One of the known weaknesses with software is that attackers can sometimes bypass its controls and carry out unintended actions. That type of attack is more difficult in Ethereum, primarily due to its smart contract implementation. Attackers can’t directly attack the blockchain and make unauthorized changes because any such changes will be immediately detected The next most likely attack vector is the smart contract interface to the blockchain data. Ethereum guarantees that smart contract code, which is translated into bytecode before it is written to the blockchain, executes on every EVM instance the same way. Also, the EVM determines when code executes and what code executes. Attackers have few opportunities to leverage smart contract code, which makes Ethereum an even more secure environment. The Ethereum platform as a whole offers possibilities that extend beyond the current uses of blockchain.