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

Using tokens and executing logic


You might be wondering how a third person could execute a call upon receiving tokens. Actually, it is ridiculously easy. This can be done in JavaScript using the Web3 library provided by Ethereum. The following is a smart contract shown on remix. We have explored remix earlier:

A smart contract

This just increments an integer, checks whether it's less than 10, and returns true if it is; it returns false otherwise. You can just use JavaScript VM for this problem. On compiling and running, if you click the SampleFunc, there will be a new entry added in the gray area. If you click on Details, you will see an input entry—you can copy this. This will be your third parameter for this function. You can execute this like any other function.

Now, if you send tokens using the ERC827 smart contract, this function will be executed.

But what is the use of this? In a word, security. A recipient can withdraw tokens, quote or unquote, and receive them. The reason for this the...