Blockchain
The Comprehensive Guide to Blockchain Development, Ethereum, Solidity, and Smart Contracts
Blockchain
The Comprehensive Guide to Blockchain Development, Ethereum, Solidity, and Smart Contracts
- Broschiertes Buch
- Merkliste
- Auf die Merkliste
- Bewerten Bewerten
- Teilen
- Produkt teilen
- Produkterinnerung
- Produkterinnerung
Demystify the blockchain-and learn how to use it-with this practical guide. Start from the ground up: What is Ethereum? What is Solidity? And how are they used to create smart contracts? Then see how to implement your own blockchain, including configuring a peer-to-peer network, managing miner accounts, and more. Follow step-by-step instructions and detailed code examples to develop smart contracts and dApps. Work with cutting-edge technologies such as Bitcoin, DeFi, NFTs, and more. Welcome to the world of blockchain!
In this book, you'll learn about:
a. Blockchain Basics You've heard…mehr
- Stefan HaasABAP Programming Model for SAP Fiori66,99 €
- Renzo ColleCore Data Services for ABAP67,99 €
- Timo OrtizSAP Interactive Forms by Adobe82,99 €
- Renzo ColleCore Data Services for ABAP68,99 €
- Bernd ÖgglGit49,95 €
- Christian UllenboomSpring Boot 3 and Spring Framework 650,99 €
- Philip AckermannJavaScript50,99 €
-
-
-
In this book, you'll learn about:
a. Blockchain Basics
You've heard the hype around Bitcoin, NFTs, and crypto mining. But how does the underlying blockchain technology work? Understand the fundamentals of the distributed ledger, and learn how to create and manage your own blockchain.
b. Application Development
Master smart contracts, from programming with Solidity to testing, debugging, deployment, and beyond. Develop decentralizedapplications (dApps) and expand them into a decentralized autonomous organization (DAO) by implementing a frontend with ether.js.
c. Tips from the Experts
Follow guidance from experienced blockchain programmers. Use commented code examples as templates for your projects to get started building your own blockchain and smart contracts in the real world.
Highlights include:
1) Blockchain basics and creation
2) Smart contracts and dApps
3) Development with Solidity
4) Testing, debugging, and security
5) Web APIs
6) Peer-to-peer frameworks
7) Accounts and balances
8) Transaction and block verification
9) Gas optimization
10) Decentralized finance (DeFi)
11) Non-fungible tokens (NFTs)
12) Yul and Huff contracts
- Produktdetails
- Verlag: Rheinwerk Computing / Rheinwerk Verlag
- Artikelnr. des Verlages: 459/22513
- Seitenzahl: 654
- Erscheinungstermin: 1. Januar 2025
- Englisch
- Abmessung: 254mm x 178mm x 34mm
- Gewicht: 1144g
- ISBN-13: 9781493225132
- ISBN-10: 1493225138
- Artikelnr.: 70311035
- Herstellerkennzeichnung
- Rheinwerk Publishing Inc.
- 2 Heritage Drive
- 11201 Quincy, MA, US
- Info@rheinwerk-verlag.de
- www.rheinwerk-verlag.de
- Verlag: Rheinwerk Computing / Rheinwerk Verlag
- Artikelnr. des Verlages: 459/22513
- Seitenzahl: 654
- Erscheinungstermin: 1. Januar 2025
- Englisch
- Abmessung: 254mm x 178mm x 34mm
- Gewicht: 1144g
- ISBN-13: 9781493225132
- ISBN-10: 1493225138
- Artikelnr.: 70311035
- Herstellerkennzeichnung
- Rheinwerk Publishing Inc.
- 2 Heritage Drive
- 11201 Quincy, MA, US
- Info@rheinwerk-verlag.de
- www.rheinwerk-verlag.de
... Preface ... 25
1 ... Introduction ... 29
1.1 ... What Is Blockchain? ... 29
1.2 ... History of Blockchain ... 36
1.3 ... Application of Blockchain Technology ... 47
1.4 ... Summary ... 66
2 ... The Basics: How Blockchain Works ... 69
2.1 ... Cryptography Basics ... 69
2.2 ... The Blockchain ... 81
2.3 ... Alternative Consensus Models ... 111
2.4 ... Blockchain Security ... 119
2.5 ... Summary ... 128
3 ... Ethereum: Blockchain 2.0 ... 131
3.1 ... Basics of Ethereum ... 132
3.2 ... From Blocks to Blockchain 2.0 ... 144
3.3 ... The Blockchain System 2.0 ... 152
3.4 ... Further Development of the Ethereum Platform ... 170
3.5 ... Summary ... 177
4 ... Fundamentals of Creating Your Own Blockchain ... 179
4.1 ... Transactions: The Smallest Units of a Blockchain ... 181
4.2 ... Block Header: Calculating the Block ID ... 183
4.3 ... Chaining Blocks ... 184
4.4 ... Storing the Blockchain State Persistently ... 186
4.5 ... The Genesis Block: Initializing a Blockchain ... 188
4.6 ... Pending Transactions ... 189
4.7 ... The Difficulty of a Blockchain ... 191
4.8 ... Let's Mine: The Miner Thread ... 192
4.9 ... Summary and Outlook ... 196
5 ... Implementing a Web API for the Blockchain ... 199
5.1 ... The Endpoints of the Web API ... 200
5.2 ... Deploying the Web API ... 205
5.3 ... Sending Transactions via a Web Interface ... 209
5.4 ... Implementing Your Own Block Explorer ... 212
5.5 ... Summary and Outlook ... 219
6 ... Implementing a Peer-to-Peer Network ... 221
6.1 ... Configuration of the Peer-to-Peer Framework ... 222
6.2 ... Broadcasting Transactions to the Network ... 225
6.3 ... Broadcasting Blocks to the Network ... 228
6.4 ... The Longest Chain Rule ... 229
6.5 ... Adding New Nodes to the Network ... 233
6.6 ... Summary and Outlook ... 235
7 ... Introducing Accounts and Balances ... 237
7.1 ... Rewarding Miners ... 238
7.2 ... Managing Accounts ... 241
7.3 ... Integrating Accounts ... 245
7.4 ... Integrating Accounts into the Block Explorer ... 246
7.5 ... Summary and Outlook ... 251
8 ... Implementing Verification and Optimizations ... 253
8.1 ... Signing Transactions ... 253
8.2 ... Enforcing Constraints ... 256
8.3 ... Locking and Unlocking Balances ... 258
8.4 ... Optimizing Performance via Merkle Trees ... 261
8.5 ... Optimizing Storage by Shortening the Public Keys ... 264
8.6 ... Supporting Initial Balances in the Genesis Block ... 265
8.7 ... Additional Optimizations ... 266
8.8 ... Summary and Outlook ... 267
9 ... Smart Contract Development ... 269
9.1 ... Smart Contract Basics ... 270
9.2 ... Simple Smart Contracts with Bitcoin Script ... 272
9.3 ... Advanced Smart Contracts ... 279
9.4 ... Contract-Oriented Programming ... 282
9.5 ... The Challenge of Random Number Generators ... 287
9.6 ... Trusting Off-Chain Data ... 291
9.7 ... Time Dependencies ... 292
9.8 ... Summary and Outlook ... 293
10 ... Integrated Development Environments and Frameworks ... 295
10.1 ... Integrated Development Environments ... 295
10.2 ... Contract-Oriented Frameworks ... 300
10.3 ... Summary and Outlook ... 313
11 ... An Introduction to Solidity ... 315
11.1 ... The Basics of Solidity ... 315
11.2 ... Elements and Data Locations of a Contract ... 319
11.3 ... Available Data Types ... 331
11.4 ... Additional Features of Solidity ... 340
11.5 ... Creating Inheritance Hierarchies of Smart Contracts ... 347
11.6 ... Creating and Using Libraries ... 352
11.7 ... Summary and Outlook ... 356
12 ... Digging Deeper into Solidity ... 359
12.1 ... Low-Level Functions in Solidity ... 359
12.2 ... Using Assembly in Solidity Smart Contracts ... 363
12.3 ... Internal Layouts of Data Locations ... 371
12.4 ... Understanding the Contract ABI ... 375
12.5 ... Understanding the Bytecode Representation of Smart Contracts ... 376
12.6 ... Summary and Outlook ... 378
13 ... Testing and Debugging Smart Contracts ... 381
13.1 ... Testing Contracts with Remix ... 382
13.2 ... Implementing Tests with Foundry ... 386
13.3 ... Implementing Tests with Hardhat ... 391
13.4 ... Debugging Smart Contracts ... 394
13.5 ... Fork Testing Ethereum-Based Chains ... 396
13.6 ... Summary and Outlook ... 398
14 ... Understanding and Optimizing Gas Costs ... 401
14.1 ... Understanding Gas Costs in Ethereum ... 401
14.2 ... Understanding the Compiler Optimizer ... 405
14.3 ... Basic Guidelines for Gas Optimization ... 407
14.4 ... Optimizations Derived from Traditional Efficiency Rules ... 411
14.5 ... Advanced Gas Optimization ... 414
14.6 ... Expert Gas Optimizations ... 418
14.7 ... Additional Optimizations for Different Use Cases ... 423
14.8 ... Helpful Tools for Gas Optimizations ... 424
14.9 ... Summary and Outlook ... 425
15 ... Protecting and Securing Smart Contracts ... 427
15.1 ... General Security Recommendations ... 427
15.2 ... Example Attacks on Smart Contracts ... 431
15.3 ... Auditing Smart Contracts via Slither ... 454
15.4 ... Summary and Outlook ... 455
16 ... Deploying and Managing Smart Contracts ... 457
16.1 ... Setting Up MetaMask and Using Accounts ... 458
16.2 ... Deploying Contracts with Remix and MetaMask ... 459
16.3 ... Deploying Contracts with Foundry ... 462
16.4 ... Deploying Contracts with Hardhat ... 465
16.5 ... Publishing and Verifying Code on Etherscan ... 469
16.6 ... Setting Up and Running Your Own Ethereum Node ... 472
16.7 ... Managing Contracts after Deployment ... 474
16.8 ... Summary and Outlook ... 476
17 ... Standards, Libraries, and Design Patterns ... 479
17.1 ... ERC-173 Contract Ownership Standard ... 479
17.2 ... ERC-165 Standardized Interface Detection ... 481
17.3 ... ERC-20 Token Standard ... 485
17.4 ... ERC-777 Token Standard ... 488
17.5 ... ERC-721 Non-Fungible Token Standard ... 489
17.6 ... ERC-1155 Multi-Token Standard ... 494
17.7 ... Using OpenZeppelin Libraries ... 496
17.8 ... The Publish-Subscribe Design Pattern ... 496
17.9 ... The Checks-Effects-Interactions Pattern ... 500
17.10 ... Summary and Outlook ... 500
18 ... Upgrading Smart Contracts ... 503
18.1 ... Basics of Upgrade Mechanisms ... 503
18.2 ... Performing Contract Migrations ... 504
18.3 ... Separation of Data and Business Logic ... 508
18.4 ... The Proxy Pattern ... 513
18.5 ... The Diamonds Pattern ... 517
18.6 ... Additional Mechanisms and Considerations ... 520
18.7 ... The Metamorphic Smart Contract Exploit ... 521
18.8 ... Summary and Outlook ... 526
19 ... Developing Decentralized Applications ... 529
19.1 ... What Is a Decentralized Application? ... 529
19.2 ... The Development Process for a DApp ... 530
19.3 ... Developing the Smart Contracts of Your First DApp ... 533
19.4 ... Developing the Off-Chain Elements of Your First DApp ... 537
19.5 ... Hosting the Frontend of Your First DApp in a Decentralized Manner ... 543
19.6 ... Setting Up ENS Domains ... 545
19.7 ... Summary and Outlook ... 550
20 ... Upgrading Your First DApp to a DAO ... 553
20.1 ... What Is a Decentralized Autonomous Organization? ... 553
20.2 ... Implementing a Governance Contract for Your DAO ... 554
20.3 ... Implementing the Frontend with Vue.js and Ethers.js ... 558
20.4 ... Ideas for Additional Backend and Oracle Services ... 568
20.5 ... Deploying Your DApp and Assigning an ENS Domain ... 569
20.6 ... Additional Frameworks, Tools, and Libraries ... 569
20.7 ... Summary and Outlook ... 571
21 ... Reverse Engineering Smart Contracts ... 573
21.1 ... Why Reverse Engineer? ... 573
21.2 ... Manual Reverse Engineering ... 575
21.3 ... Manual Recovery of a Contract ABI ... 586
21.4 ... Tools for Reverse Engineering Smart Contracts ... 590
21.5 ... Summary and Outlook ... 594
22 ... Additional Contract-Oriented Programming Languages ... 595
22.1 ... Yul: The Intermediate Language for Different Backends ... 596
22.2 ... Huff: Highly Optimized Smart Contracts ... 605
22.3 ... Vyper: Smart Contracts for Everyone? ... 610
22.4 ... Comparison of Gas Costs ... 614
22.5 ... Summary and Outlook ... 615
23 ... Applying Blockchain Technologies ... 617
23.1 ... Decentralized Finance ... 617
23.2 ... Developing and Minting NFTs ... 622
23.3 ... Ethereum Layer 2 Solutions ... 629
23.4 ... Other Blockchain 2.0 Projects ... 631
23.5 ... A Different Blockchain Approach: Ripple ... 633
23.6 ... Summary ... 635
... Appendices ... 637
A ... Bibliography ... 637
B ... The Authors ... 639
... Index ... 641
... Preface ... 25
1 ... Introduction ... 29
1.1 ... What Is Blockchain? ... 29
1.2 ... History of Blockchain ... 36
1.3 ... Application of Blockchain Technology ... 47
1.4 ... Summary ... 66
2 ... The Basics: How Blockchain Works ... 69
2.1 ... Cryptography Basics ... 69
2.2 ... The Blockchain ... 81
2.3 ... Alternative Consensus Models ... 111
2.4 ... Blockchain Security ... 119
2.5 ... Summary ... 128
3 ... Ethereum: Blockchain 2.0 ... 131
3.1 ... Basics of Ethereum ... 132
3.2 ... From Blocks to Blockchain 2.0 ... 144
3.3 ... The Blockchain System 2.0 ... 152
3.4 ... Further Development of the Ethereum Platform ... 170
3.5 ... Summary ... 177
4 ... Fundamentals of Creating Your Own Blockchain ... 179
4.1 ... Transactions: The Smallest Units of a Blockchain ... 181
4.2 ... Block Header: Calculating the Block ID ... 183
4.3 ... Chaining Blocks ... 184
4.4 ... Storing the Blockchain State Persistently ... 186
4.5 ... The Genesis Block: Initializing a Blockchain ... 188
4.6 ... Pending Transactions ... 189
4.7 ... The Difficulty of a Blockchain ... 191
4.8 ... Let's Mine: The Miner Thread ... 192
4.9 ... Summary and Outlook ... 196
5 ... Implementing a Web API for the Blockchain ... 199
5.1 ... The Endpoints of the Web API ... 200
5.2 ... Deploying the Web API ... 205
5.3 ... Sending Transactions via a Web Interface ... 209
5.4 ... Implementing Your Own Block Explorer ... 212
5.5 ... Summary and Outlook ... 219
6 ... Implementing a Peer-to-Peer Network ... 221
6.1 ... Configuration of the Peer-to-Peer Framework ... 222
6.2 ... Broadcasting Transactions to the Network ... 225
6.3 ... Broadcasting Blocks to the Network ... 228
6.4 ... The Longest Chain Rule ... 229
6.5 ... Adding New Nodes to the Network ... 233
6.6 ... Summary and Outlook ... 235
7 ... Introducing Accounts and Balances ... 237
7.1 ... Rewarding Miners ... 238
7.2 ... Managing Accounts ... 241
7.3 ... Integrating Accounts ... 245
7.4 ... Integrating Accounts into the Block Explorer ... 246
7.5 ... Summary and Outlook ... 251
8 ... Implementing Verification and Optimizations ... 253
8.1 ... Signing Transactions ... 253
8.2 ... Enforcing Constraints ... 256
8.3 ... Locking and Unlocking Balances ... 258
8.4 ... Optimizing Performance via Merkle Trees ... 261
8.5 ... Optimizing Storage by Shortening the Public Keys ... 264
8.6 ... Supporting Initial Balances in the Genesis Block ... 265
8.7 ... Additional Optimizations ... 266
8.8 ... Summary and Outlook ... 267
9 ... Smart Contract Development ... 269
9.1 ... Smart Contract Basics ... 270
9.2 ... Simple Smart Contracts with Bitcoin Script ... 272
9.3 ... Advanced Smart Contracts ... 279
9.4 ... Contract-Oriented Programming ... 282
9.5 ... The Challenge of Random Number Generators ... 287
9.6 ... Trusting Off-Chain Data ... 291
9.7 ... Time Dependencies ... 292
9.8 ... Summary and Outlook ... 293
10 ... Integrated Development Environments and Frameworks ... 295
10.1 ... Integrated Development Environments ... 295
10.2 ... Contract-Oriented Frameworks ... 300
10.3 ... Summary and Outlook ... 313
11 ... An Introduction to Solidity ... 315
11.1 ... The Basics of Solidity ... 315
11.2 ... Elements and Data Locations of a Contract ... 319
11.3 ... Available Data Types ... 331
11.4 ... Additional Features of Solidity ... 340
11.5 ... Creating Inheritance Hierarchies of Smart Contracts ... 347
11.6 ... Creating and Using Libraries ... 352
11.7 ... Summary and Outlook ... 356
12 ... Digging Deeper into Solidity ... 359
12.1 ... Low-Level Functions in Solidity ... 359
12.2 ... Using Assembly in Solidity Smart Contracts ... 363
12.3 ... Internal Layouts of Data Locations ... 371
12.4 ... Understanding the Contract ABI ... 375
12.5 ... Understanding the Bytecode Representation of Smart Contracts ... 376
12.6 ... Summary and Outlook ... 378
13 ... Testing and Debugging Smart Contracts ... 381
13.1 ... Testing Contracts with Remix ... 382
13.2 ... Implementing Tests with Foundry ... 386
13.3 ... Implementing Tests with Hardhat ... 391
13.4 ... Debugging Smart Contracts ... 394
13.5 ... Fork Testing Ethereum-Based Chains ... 396
13.6 ... Summary and Outlook ... 398
14 ... Understanding and Optimizing Gas Costs ... 401
14.1 ... Understanding Gas Costs in Ethereum ... 401
14.2 ... Understanding the Compiler Optimizer ... 405
14.3 ... Basic Guidelines for Gas Optimization ... 407
14.4 ... Optimizations Derived from Traditional Efficiency Rules ... 411
14.5 ... Advanced Gas Optimization ... 414
14.6 ... Expert Gas Optimizations ... 418
14.7 ... Additional Optimizations for Different Use Cases ... 423
14.8 ... Helpful Tools for Gas Optimizations ... 424
14.9 ... Summary and Outlook ... 425
15 ... Protecting and Securing Smart Contracts ... 427
15.1 ... General Security Recommendations ... 427
15.2 ... Example Attacks on Smart Contracts ... 431
15.3 ... Auditing Smart Contracts via Slither ... 454
15.4 ... Summary and Outlook ... 455
16 ... Deploying and Managing Smart Contracts ... 457
16.1 ... Setting Up MetaMask and Using Accounts ... 458
16.2 ... Deploying Contracts with Remix and MetaMask ... 459
16.3 ... Deploying Contracts with Foundry ... 462
16.4 ... Deploying Contracts with Hardhat ... 465
16.5 ... Publishing and Verifying Code on Etherscan ... 469
16.6 ... Setting Up and Running Your Own Ethereum Node ... 472
16.7 ... Managing Contracts after Deployment ... 474
16.8 ... Summary and Outlook ... 476
17 ... Standards, Libraries, and Design Patterns ... 479
17.1 ... ERC-173 Contract Ownership Standard ... 479
17.2 ... ERC-165 Standardized Interface Detection ... 481
17.3 ... ERC-20 Token Standard ... 485
17.4 ... ERC-777 Token Standard ... 488
17.5 ... ERC-721 Non-Fungible Token Standard ... 489
17.6 ... ERC-1155 Multi-Token Standard ... 494
17.7 ... Using OpenZeppelin Libraries ... 496
17.8 ... The Publish-Subscribe Design Pattern ... 496
17.9 ... The Checks-Effects-Interactions Pattern ... 500
17.10 ... Summary and Outlook ... 500
18 ... Upgrading Smart Contracts ... 503
18.1 ... Basics of Upgrade Mechanisms ... 503
18.2 ... Performing Contract Migrations ... 504
18.3 ... Separation of Data and Business Logic ... 508
18.4 ... The Proxy Pattern ... 513
18.5 ... The Diamonds Pattern ... 517
18.6 ... Additional Mechanisms and Considerations ... 520
18.7 ... The Metamorphic Smart Contract Exploit ... 521
18.8 ... Summary and Outlook ... 526
19 ... Developing Decentralized Applications ... 529
19.1 ... What Is a Decentralized Application? ... 529
19.2 ... The Development Process for a DApp ... 530
19.3 ... Developing the Smart Contracts of Your First DApp ... 533
19.4 ... Developing the Off-Chain Elements of Your First DApp ... 537
19.5 ... Hosting the Frontend of Your First DApp in a Decentralized Manner ... 543
19.6 ... Setting Up ENS Domains ... 545
19.7 ... Summary and Outlook ... 550
20 ... Upgrading Your First DApp to a DAO ... 553
20.1 ... What Is a Decentralized Autonomous Organization? ... 553
20.2 ... Implementing a Governance Contract for Your DAO ... 554
20.3 ... Implementing the Frontend with Vue.js and Ethers.js ... 558
20.4 ... Ideas for Additional Backend and Oracle Services ... 568
20.5 ... Deploying Your DApp and Assigning an ENS Domain ... 569
20.6 ... Additional Frameworks, Tools, and Libraries ... 569
20.7 ... Summary and Outlook ... 571
21 ... Reverse Engineering Smart Contracts ... 573
21.1 ... Why Reverse Engineer? ... 573
21.2 ... Manual Reverse Engineering ... 575
21.3 ... Manual Recovery of a Contract ABI ... 586
21.4 ... Tools for Reverse Engineering Smart Contracts ... 590
21.5 ... Summary and Outlook ... 594
22 ... Additional Contract-Oriented Programming Languages ... 595
22.1 ... Yul: The Intermediate Language for Different Backends ... 596
22.2 ... Huff: Highly Optimized Smart Contracts ... 605
22.3 ... Vyper: Smart Contracts for Everyone? ... 610
22.4 ... Comparison of Gas Costs ... 614
22.5 ... Summary and Outlook ... 615
23 ... Applying Blockchain Technologies ... 617
23.1 ... Decentralized Finance ... 617
23.2 ... Developing and Minting NFTs ... 622
23.3 ... Ethereum Layer 2 Solutions ... 629
23.4 ... Other Blockchain 2.0 Projects ... 631
23.5 ... A Different Blockchain Approach: Ripple ... 633
23.6 ... Summary ... 635
... Appendices ... 637
A ... Bibliography ... 637
B ... The Authors ... 639
... Index ... 641