Hands-On Blockchain for Python Developers - Arjuna Sky Kok - E-Book

Hands-On Blockchain for Python Developers E-Book

Arjuna Sky Kok

0,0
34,79 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

We are living in the age of decentralized fi nance and NFTs. People swap tokens on Uniswap, borrow assets from Aave, send payments with stablecoins, trade art NFTs on OpenSea, and more. To build applications of this kind, you need to know how to write smart contracts.
This comprehensive guide will help you explore all the features of Vyper, a programming language designed to write smart contracts. You’ll also explore the web3.py library. As you progress, you’ll learn how to connect to smart contracts, read values, and create transactions. To make sure your foundational knowledge is strong enough, the book guides you through Ape Framework, which can help you create decentralized exchanges, NFT marketplaces, voting applications, and more. Each project provides invaluable insights and hands-on experience, equipping you with the skills you need to build real-world blockchain solutions.
By the end of this book, you’ll be well versed with writing common Web3 applications such as a decentralized exchange, an NFT marketplace, a voting application, and more.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 522

Veröffentlichungsjahr: 2024

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Hands-On Blockchain for Python Developers

Empowering Python developers in the world of blockchain and smart contracts

Arjuna Sky Kok

Hands-On Blockchain for Python Developers

Copyright © 2024 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Group Product Manager: Kunal Sawant

Publishing Product Manager: Akash Sharma

Senior Editor: Esha Banerjee

Technical Editor: Jubit Pincy

Copy Editor: Safis Editing

Project Coordinator: Manisha Singh

Indexer: Manju Arasan

Production Designer: Jyoti Kadam

Marketing Coordinator: Sonia Chauhan

First published: February 2019

Second edition: June 2024

Production reference: 1130624

Published by Packt Publishing Ltd.

Grosvenor House

11 St Paul's Square

Birmingham

B3 1RB, UK.

ISBN 978-1-80512-136-7

www.packtpub.com

To the memory of my brother, Hengdra Santoso, for the unbreakable bond we shared as brothers.

– Arjuna Sky Kok

Contributors

About the author

Arjuna Sky Kok is a skilled software engineer with a passion for all things related to finance and technology. He lives in Jakarta, where he studied mathematics and programming at Binus University. Arjuna’s academic achievements include double degrees in Computer Science and Mathematics. Currently, he is focusing his talent in the crypto space, as he believes that DeFi and NFT will serve as the foundation for future finance. He also has a keen interest in AI, especially Generative AI. Outside of work, Arjuna enjoys watching anime, listening to J-pop songs, and playing basketball.

About the reviewers

Ankit Anchlia is a distinguished software development professional with over a decade of industry experience. With a background in software development, Ankit brings a wealth of expertise and insights to the table. Ankit has served as a judge at numerous hackathons and has evaluated projects for prestigious awards such as the Webby, Edison, and Globee Awards. Beyond his professional achievements, Ankit is an active contributor to the software development community. He regularly shares valuable insights through articles in tech blogs, influencing and inspiring fellow developers. As a member of The International Academy of Digital Arts and Sciences (IADAS), Ankit continues to shape the future of digital innovation.

Shivanjan Chakravorty is a distinguished Member of Technical Staff 3 at Pure Storage, where he brings a wealth of expertise to the forefront of technological innovation. Renowned for his contributions to open-source projects, especially libopenstorage, Shivanjan excels in Golang and Python. His expertise covers a wide range of technologies including Kubernetes, Machine Learning, and Generative AI. He has also worked extensively with Large Language Models (LLMs). Additionally, his scholarly work includes two published research papers in the domain of mathematical optimization. Beyond his professional pursuits, Shivanjan is an avid adventurer and a chess enthusiast, embodying a dynamic blend of intellect and passion.

Table of Contents

Preface

Part 1: Blockchain and Smart Contract

1

Introduction to Blockchain Programming

Technical requirements

The rise of cryptocurrency and blockchain

Blockchain technology

Signing data in blockchain

From linked list to blockchain

Cryptography

Symmetric and asymmetric cryptography

The hashing function

Proof of work

Consensus

Blockchain as a technology that prevents cheating

Proof of stake

Coding on the blockchain

Other types of blockchain programmers

What does it mean to be a blockchain programmer?

The scope of this book

Summary

References

2

Smart Contract Fundamentals

Technical requirements

Smart contract

Secure from cheating

Censorship resistance

Practical applications

Summary

3

Using Vyper to Implement a Smart Contract

Technical requirements

Setting up Vyper

Data types

Boolean

Signed integer

Unsigned integer

Decimal

Address

Fixed-size byte array

Byte array

String

Enum

List

Dynamic arrays

Struct

Mapping

Functions

Mutability

Control structures

Environment variables

Event logging

Interface

Summary

Part 2: Web3 and Ape Framework

4

Using Web3.py to Interact with Smart Contracts

Technical requirements

Installing web3.py

Ganache

Geth

Deploying a smart contract

Interacting with smart contracts

Summary

5

Ape Framework

Technical requirements

Installing Ape Framework

Developing smart contracts

Compiling a smart contract

Deploying the smart contract

Testing smart contracts

Networks in blockchain

Summary

6

Building a Practical Decentralized Application

Technical requirements

Writing the voting smart contract

Writing the unit test of the voting smart contract

Adding delegation to the voting smart contract

The benefits of the decentralized nature of a voting smart contract

Ideas for improvements

Summary

Part 3: Graphical User Interface Applications

7

Front-End Decentralized Application

Technical requirements

Using the voting smart contract with scripts

Compiling the smart contract

Creating accounts

Setting up the Geth development blockchain

Deploying the smart contract onto blockchain

Creating and running the scripts

Installing the PySide library

Creating the voting GUI application

Connecting the GUI application with the smart contract

Summary

8

Cryptocurrency Wallet

Technical requirements

What is a wallet?

Mnemonic keys

Developing a cryptocurrency wallet

Wallet UX

Summary

Part 4: Related Technologies

9

InterPlanetary: A Brave New File System

Technical requirements

The motivation behind IPFS

Merkle DAG

Merkle tree

Directed Acrylic Graph

Content addressing

The Merkle DAG data structure

Peer-to-peer networking

The notion of proximity of data and nodes

XOR distance

Buckets

Summary

10

Implementing a Decentralized Application Using IPFS

Technical requirements

Installing the IPFS software and its library

Exploring the IPFS Python library

The architecture of the decentralized video-sharing application

The architecture of the video-sharing smart contract

The architecture of the video-sharing web application

Writing the video-sharing smart contract

Creating a Bootstrap script

Building the video-sharing web application

Views

Models

Templates

URLs

Demo

Summary

11

Exploring Layer 2

Technical requirements

Understanding L2

How L2 works

Optimistic rollups

Zk rollups

Looking at examples of L2

Polygon

Arbitrum

Optimism

Base

Starknet

zkSync

Deploying smart contracts to L2

Introducing the bridge technology

Bridging ETH

Bridging ERC-20 tokens

Native ERC-20 tokens

Messages

Sending messages from L1 to L2

Sending messages from L2 to L1

Sending messages across L2s

Sending messages across blockchains

Summary

Part 5: Cryptocurrency and NFT

12

Creating Tokens on Ethereum

Technical requirements

How to create a simple token smart contract

The ERC-20 token standard

Selling tokens

Security aspects

Summary

13

How to Create an NFT

Technical requirements

What is an NFT?

ERC-721 standard

Creating the NFT smart contract

Interfaces, events, and state variables

Implementing functions

Unit tests

Summary

Part 6: Writing Complex Smart Contracts

14

Writing NFT Marketplace Smart Contracts

Technical requirements

Understanding the NFT marketplace

Writing the NFT marketplace smart contract

Writing the tests

Enhancing the NFT marketplace

Supporting non-standard NFTs

Supporting ERC-20 tokens

Summary

15

Writing a Lending Vault Smart Contract

Technical requirements

Understanding vaults

The ERC-4626 standard

Lending application

Summary

16

Decentralized Exchange

Technical requirements

Exploring DEXs

Understanding AMM

Market makers

How AMM works

Writing a DEX smart contract

Unit tests

Summary

Part 7: Building a Full-Stack Web3 Application

17

Token-Gated Applications

Technical requirement

Understanding a token-gated application

Creating a signature

ERC-4361

Installing a wallet browser extension

Deploying a token smart contract

Writing a backend application

Writing a frontend application

Summary

Index

Other Books You May Enjoy

Part 1:Blockchain and Smart Contract

In this section, you’ll get an overview of the world of decentralized applications. This part begins by introducing the core concepts and principles of blockchain technology, followed by an in-depth exploration of smart contracts – the self-executing programs that enable trustless and automated transactions on the blockchain. Through hands-on examples, you’ll gain practical experience in implementing smart contracts using the Vyper language, setting the stage for building secure and robust decentralized applications.

This section has the following chapters:

Chapter 1, Introduction to Blockchain ProgrammingChapter 2, Smart Contract FundamentalsChapter 3, Using Vyper to Implement a Smart Contract