Blockchain Engineering Playbook
Blockchain Engineering Playbook
Engineering
Playbook
2025
Rohas Nagpal
Version 1.7 dated 2 January 2025
This book is part of the Official Courseware of the
Blockchain Engineering Program
conducted by Rohas Nagpal.
How Blockchain Engineering skills will help you
3
Contents
1. Blockchain Basics..............................................................8
1.1 Blockchain Nodes..........................................................14
1.2 Mining...............................................................................17
1.3 Layers of a Blockchain Network................................18
1.4 Types of Blockchains....................................................20
1.5 Blockchain Consensus Mechanisms.........................23
1.6 Blockchain Bridges........................................................27
1.7 Blockchain Metrics........................................................30
1.8 Merged Mining................................................................32
1.9 Blockchain Forks...........................................................34
1.10 Blockchain Addresses................................................36
1.11 Blockchain Wallets.....................................................38
1.12 Blockchain Record-keeping Models........................42
1.13 Asset Tokenization......................................................44
1.14 Smart Contracts..........................................................49
1.15 Blockchain use-cases.................................................52
2. Blockchain APIs...............................................................56
5. Bitcoin................................................................................92
6. Ethereum Standards.......................................................97
7. Multichain.......................................................................106
8. HYFI Blockchain............................................................121
9. Hyperledger....................................................................134
6
(c) 2023-25 Rohas Nagpal. All rights reserved.
8
01
Blockchain
Basics
A blockchain:
● is a linear, chronological structure
● consists of blocks of data (transactions) that are
chained together.
10
Conceptual Image of a Blockchain Network
11
While Blockchains have a linear chronological
structure, Distributed Ledger Technologies (DLTs) can
have different structures, such as:
12
13
14
1.1 Blockchain Nodes
15
A conceptual overview of a Blockchain Node
16
Archival Full Nodes
They are the most important. They host the entire
blockchain, validate blocks & maintain consensus.
Master nodes
Users run masternodes to earn network rewards. Some
amount of native tokens have to be "locked" by
masternode operators.
Light nodes
A light node does not hold the full copy of the
blockchain. It saves download time & storage space by
only downloading block headers.
Cold nodes
They are used for signing transactions offline and
storing private keys away from the network.
Lightning nodes
They reduce the load on the network by enabling
off-chain transactions. These nodes enable faster and
cheaper transactions.
17
1.2 Mining
18
1.3 Layers of a Blockchain Network
19
20
1.4 Types of Blockchains
Layer-0 Blockchains
21
Layer-1 Blockchains
Layer-2 Blockchains
Permission-less blockchains
Permissioned blockchains
22
Federated blockchains
EVM-compatible chains
23
1.5 Blockchain Consensus
Mechanisms
Proof-of-Work (PoW)
This was the world’s first consensus algorithm. Miners
"solve" mathematical puzzles by investing in electricity
and computational power e.g. Bitcoin.
24
Proof-of-Work-Time (PoWT)
This features a variable blocktime that scales with
mining power. The blockchain speeds up with power
increases. This mechanism scales the blockchain well
and increases transaction speed with power.
Proof-of-replication (PoRep)
Storage miners prove 2 things:
● that they are using space to store replicas of
data,
● that the data can easily be accessed.
25
Delegated Proof of Stake (DPoS)
Holders "lock" a number of coins as a "stake" but
outsource validation to "delegates" selected based on
reputation and trustworthiness e.g. Bitshares.
Proof-of-Spacetime (PoSt)
Randomly selected miners prove that they have been
physically storing data for a certain period of time e.g.
Filecoin.
Proof-of-burn (PoB)
Miners reach a consensus by sending coins to an
"eater" or "burn" address. This permanently eliminates
coins from circulation, reduces inflation, and validates
transactions e.g. Slimcoin.
Proof-of-Authority (PoA)
Identified, known, and credible validators produce
blocks in this system. It is meant for private &
enterprise blockchains.
26
This mindmap shows 82 blockchain consensus
mechanisms divided into 9 categories.
27
1.6 Blockchain Bridges
28
In simple terms, here's how a typical bridge works:
29
Ronin worked "off-chain" - it interfaced with the
blockchain but existed on external servers that were
not a part of the blockchain.
30
1.7 Blockchain Metrics
Throughput
Throughput is the number of transactions per second
that a Blockchain consensus algorithm can process.
Finality
Finality (also called Latency) represents the time it
takes for a transaction to be settled in the "ledger" of a
blockchain.
Scalability
Scalability is the ability of a blockchain to expand
without degrading performance.
Bitcoin
● Throughput: 7 tps
● Threshold: 51%
● Finality: 60 min
31
Ethereum Mainnet
● Throughput: 14 tps
● Threshold: 51%
● Finality: 6 min
Polkadot
● Throughput: 1500 tps
● Threshold: 33%
● Finality: 60 secs
32
1.8 Merged Mining
33
Merged Mining increases the profitability and
performance of mining and is hugely beneficial for
miners.
34
1.9 Blockchain Forks
Hard Fork
Soft Fork
Ethereum Fork
35
But a hacker exploited a bug in the "smart contract"
and siphoned out all the money!
36
1.10 Blockchain Addresses
b5ba96aae89dc703c27ec5b3d478a8b176b874f248c8
3e533d9edc18e6356d44
37
This is what happens in most crypto ‘hacks’.
That's why we say that "Not your keys, not your coins".
Sample WIF
L3Jy6k2KCJ6uDNEj1hirw49sPWghT7Cg77rSDvfpAkA
C7F63PhGe
Sample Address
1AAE1EDcCAUmyBfi46G3vpik8oCaKVoabT
38
1.11 Blockchain Wallets
39
Paper wallets are inconvenient to use but are the
safest option. Consider using them if you have a large
number of crypto assets to keep for a long period of
time.
Site: https://www.bitaddress.org
40
Hardware wallets are a little pricey and there’s always
the risk of losing or breaking them.
41
So remember to back up the seed phrase - a bunch of
words that you can write down. Example:
history
lumber
quote
board
young
dove
robust
kit
invite
plastic
regular
skull
42
1.12 Blockchain Record-keeping Models
44
1.13 Asset Tokenization
45
1. What are Illiquid Assets?
Examples:
46
6. Real Estate: Properties including residential,
commercial, industrial, and agricultural.
2. What is Tokenization?
47
4. Bringing liquidity to markets that are traditionally
illiquid.
48
Download the
Tokenization Playbook by Rohas Nagpal
rohasnagpal.com/docs/Tokenization_Playbook.pdf
49
1.14 Smart Contracts
Smart contracts:
● financial transactions,
● supply chain management,
● digital identity,
● legal agreements.
50
Here's the code for a very basic smart contract called
"HelloWorld".
51
● The constructor function executes automatically
when the contract is first deployed. In this case, it
sets the initial value of the "message" variable to
"Hello, World!".
52
1.15 Blockchain use-cases
53
● Electronic health record management
● Digital evidence management system
● Public service delivery
● Blockchain for social good use cases (charity,
donations)
● Metering and settlement
● Payment security mechanism
● Authentication and authorization services
● Automated control of decentralized power
● Smart grid application and grid management
● Microfinance for Self-Help Groups (SHG)
● Customs and trade finance
● Cross border trade
● Renewable energy trading and management
● Insurance underwriting and claims management
● Aggrotech environment
● Micro-financing, financing small businesses or
individuals
● Secured logistics document exchange (SLDE)
● Cold chain for supply chain
● National and state highways, toll collection,
tracking of public infrastructure
● Blockchain for urban development tracking
through Public Private Partnership
● Tracking the progress on climate agreement
through Blockchain
54
● Asset transfer across different government
departments
● Digital identities, and verifiable credentials to
secure privacy and enable new use cases
● Safe and secure vaccine distribution and
administration
● IoT device management and security
● Vehicle lifecycle management
● Chit fund operation and administration
55
56
02
Blockchain
API
2. Blockchain API
Start with this video:
https://www.youtube.com/live/mX-WNX3C6VQ?featur
e=share&t=52
1. Private Key
58
A private key can be represented in multiple formats:
2. Public Key
59
3. Address
61
6. Hierarchical Deterministic Wallets
{
"address":
"0xa7673161CbfE0116A4De9E341f8465940c2211d4"
}
https://gist.github.com/rohasnagpal/c791fd4573e8408
8437688a4859ae673#file-generate-private-key
{"key":"cMotAJwwC3hruht3gYKBBLm9kUhEWvfovDTL
GPy4biyNbR2VBXLG"}
63
Sample BTC HD Wallet:
https://www.rohasnagpal.com/web3/files/hd_wallet_bt
c.php
64
03
Network
Security
& Privacy
3.1 Blockchain Network Attacks &
Vulnerabilities
51% Attack
Sybil Attack
Eclipse Attack
Routing Attack
Replay Attack
Timejacking Attack
67
Phishing Attacks
68
3.2 Node Security Best Practices
Securing a blockchain node is essential to maintain the
integrity of the overall network and to protect the
information stored within the node.
69
❏ Role-Based Access Control: Use Role-Based
Access Control (RBAC) to limit who can access
what resources. It should be ensured that users
and applications only have the permissions that
they need and nothing more.
70
❏ Patch Management: Regularly apply security
patches to all software. Unpatched software can
be a security vulnerability.
71
3.3 Network Monitoring Tools
Network monitoring is an essential part of maintaining
a healthy and secure blockchain node.
Wireshark
Nagios
Zabbix
72
Prometheus
Netdata
IFTOP
73
TCPdump
74
3.4 Privacy Enhancing Technologies
Privacy Enhancing Technologies (PETs) are designed to
uphold data minimization principles and allow
individuals to retain control and ownership of their
personal data.
Ring Signatures
75
Coin Mixing or CoinJoin
Mimblewimble
Homomorphic Encryption
76
Secure Multi-Party Computation (sMPC)
Tor/I2P Networks
77
Download the Blockchain Security Controls from:
https://www.rohasnagpal.com/docs/blockchain-security/blockc
hain_security_controls.pdf
78
04
Node Maintenance
& Performance
Optimization
4.1 Blockchain Data Storage and
Management
In a blockchain network, data storage and management
is a crucial aspect of maintaining efficient operations
and reliability.
Blockchain Structure
On-Chain Storage
80
Off-Chain Storage
Sharding
81
Pruning
State Channels
Database Management
Backups
82
A combination of these techniques can be used
depending on the specific use case and requirements.
83
4.2 Node Performance Metrics
Node performance metrics help in understanding the
overall health and efficiency of a blockchain node.
Memory Usage
CPU Usage
Disk Usage
85
Uptime
86
4.3 Performance Tuning &
Optimization
Performance tuning and optimization for a blockchain
node involves identifying and resolving issues that
hinder its efficiency and reliability. Here are some
strategies:
Hardware Upgrade
OS Optimization
Database Optimization
87
Node Configuration
Sharding
Off-Chain Transactions
Pruning
88
Network Optimization
89
4.4 Backup & Disaster Recovery
Backup and disaster recovery are crucial aspects of
maintaining a reliable and resilient blockchain node.
Regular Backups
Offsite Storage
Secure Storage
Redundancy
Failover Mechanisms
Backup Software
Documentation
91
Node Software Backups
92
05
Bitcoin
If blockchain technology were a religion, the Bitcoin
whitepaper would be its Bible.
https://www.youtube.com/watch?v=3BBRF1XgjTE&t=75s
94
95
Setting up a Bitcoin node
96
This file allows you to set various parameters, such as
enabling RPC (Remote Procedure Call) for interacting
with your node.
97
06
Ethereum
Ethereum is NOT a blockchain. It's NOT a
cryptocurrency either! It's actually a protocol (a set of
rules or procedures) like "HTTP" or "HTTPS".
Ethereum standards
101
ERC-3525: Semi-Fungible Token
A standard for for tokens with both fungible and
non-fungible characteristics for representing a wide
range of assets with varying attributes.
105
After installation, open a terminal or command prompt.
3. Creating an Account
106
07
Multichain
Multichain is a framework for creating permissioned
blockchains.
● https://www.multichain.com/download-community
● https://www.multichain.com/developers/creating-co
nnecting
108
Practical 2: Addresses & Permissions
https://www.youtube.com/live/mZk1K0NEUyw?feature
=share&t=102
getnewaddress
Returns a new custodial address whose private key is
added to the wallet.
getaddresses true
Returns a list of addresses in this node’s wallet with
more information about each address,
109
getaddresses false
Returns a list of addresses in this node’s wallet.
listaddresses
Returns information about the addresses in the wallet.
createkeypairs
validateaddress
110
importaddress
connect
to connect to other nodes and see the blockchain’s
contents
send
to send funds
receive
to receive funds
issue
to create new native assets
create
to create data streams
111
mine
to create blocks
activate
to change connect, send and receive permissions for
other users
admin
to change all permissions for other users, including
issue, mine, activate and admin
listpermissions
Returns a list of all permissions which have been
explicitly granted to addresses.
112
Practical 3: Smart Asset Management
listpermissions issue
listaddresses
113
If there is no address with issue permissions, you can
give an address this permission using this:
Depending upon the use case, the issue from and issue
to addresses can be the same.
114
● Can open and Can close: Whether to allow the
asset to be closed and/or (re)opened for future
issuance using the update command.
115
See the sample code for issuing this asset:
https://gist.github.com/rohasnagpal/610a906ff2954fe7
2c5f14b6959d8b11
listassets
displays details of all assets
listassets <identifier>
Displays details of asset having the specified:
● Name e.g. Cessna-Skyhawk-172.8
● Issuance transaction ID e.g. 269-266-32631
● Asset reference number e.g.
777feac622d9af4c5ae91f8cdb62f3575e3153093
0feecf839e9febaa8567f63
or
or
update
777feac622d9af4c5ae91f8cdb62f3575e31530930feecf
839e9febaa8567f63 '{"open":true}'
116
117
Step 5: Issue more tokens (Optional)
issuemorefrom
1WQ65QwRZFyvUDhUDFKTHBgPqEYvA1C5vRNxyU
1WQ65QwRZFyvUDhUDFKTHBgPqEYvA1C5vRNxyU
Cessna-Skyhawk-172.8 2500 0 '{"Metadata":"Reasons
for issuing more tokens e.g. token split"}'
Examples:
118
Practical 4: Atomic Exchange Transactions
https://www.multichain.com/developers/atomic-excha
nge-transactions
119
Production blockchain parameters
120
Cold nodes and wallets
121
08
HYFI Blockchain
Hybrid Finance Blockchain (HYFI) is a Legally-compliant
Permissioned Layer-1 Blockchain for the Tokenization
of Real World Assets (Authentication, Provenance,
Fractional Ownership, and Trading).
Website: https://www.hyfiblockchain.com/
123
3. How HYFI provides Enhanced Privacy:
As a permissioned blockchain, HYFI members have
control over who can access the network. This helps to
keep sensitive data confidential.
124
8.2 Legal & regulatory compliance
Hybrid Finance (HYFI) Blockchain supports regulatory
compliance in 7 ways:
125
3. How HYFI supports CFT (Countering the Financing
of Terrorism)
126
Role-based asset controls allow for business,
compliance, and regulatory oversight.
127
2. The P2P connections in HYFI Blockchain are fully
encrypted, preventing intermediate routers from
seeing any private data.
128
8.4 HYFI Scalability Features
Some of the scalability features of Hybrid Finance
(HYFI) Blockchain are:
129
6. The scalability of the HYFI Blockchain is
improved through Selective Stream Indexing and
Selective Data Retrieval.
130
8.6 Integrating HYFI with other
applications
Hybrid Finance (HYFI) Blockchain can be integrated
with other applications through its unified JSON-RPC
API.
131
By providing a simple and flexible API, HYFI enables
developers to create a wide range of custom
applications, from simple web interfaces to complex
decentralized applications (dApps), that can interact
with the blockchain in a secure and efficient manner.
132
Data streams provide a mechanism for organizing &
managing data within the blockchain in a secure and
scalable manner, making it possible for a wide range of
use cases, including but not limited to, content
distribution, copyright licensing, and secure data
sharing.
133
Smart Filters are written in JavaScript and run within a
deterministic version of Google’s V8 JavaScript engine,
which is embedded directly within MultiChain 2.
1. HYFI Nodes
2. Addresses
3. Tokenizing Assets on HYFI Blockchain
4. Transactions
134
09
Hyperledger
Hyperledger is an open-source initiative for growing
enterprise use of blockchain technologies.
Distributed Ledgers
Libraries
136
Tools
137
Hyperledger Besu
138
Hyperledger Fabric
139
Hyperledger Indy
140
Hyperledger Iroha
141
Hyperledger Sawtooth
142
AnonCreds
143
Aries
144
Transact
145
Ursa
146
Bevel
147
Cacti
148
Caliper
149
Cello
150
Firefly
151
Solang
152
10
Blockchain & Web3
Tech Stack
1. Akash Network
2. Alchemy
154
● Mempool Visualizer enables troubleshooting
transactions that may be delayed, stuck or
dropped in the mempool.
3. API3
4. Aragon
Aragon App is a simple, modular and adaptable DAO
platform.
155
Aragon Client is a DAO platform for communities to
raise funds, pay contributors, and govern together.
Aragon Voice is a gasless and universally verifiable
voting solution for web3.
5. Arweave
6. Audius
156
Audius is built on both Ethereum and Solana.
7. Band Protocol
157
● Content creators earn ad revenue, user
contributions, and tips.
9. Chainlink
158
How can a smart contract get data from the outside
world? That's the problem that Oracles solve. They act
as middleware between smart contracts and external
sources of data.
159
LINK is the crypto token that is used for paying
Chainlink node operators for providing oracle services.
12. Drizzle
160
13. Ethereum Name Service
14. Filecoin
161
Filecoin is integrated with Ethereum. This enables
developers to access Ethereum blockchain data and
interact with Ethereum smart contracts.
15. Ganache
162
16. Gnosis Safe
163
The Helium network is a decentralized wireless
network. It enables IoT devices to wirelessly connect to
the Internet and geolocate themselves without satellite
location hardware or cellular plans.
18. Infura
19. IPFS
164
Traditional URLs & file paths identify a file by where it's
located.
Examples:
https://www.rohasnagpal.com/web3/index.html
file:///Users/sanyanagpal/Documents/hyfi.pdf
165
20. Livepeer
21. Moralis
166
22. NuCypher
24. Ontology
25. OpenZeppelin
167
OpenZeppelin Defender manages smart contract
administration including access controls, upgrades, and
pausing. It Works with popular multi-sigs including
Gnosis Safe.
168
28. Sia
169
Step 3: Files are sent to hosts using smart contracts -
Storage renters enter into file contracts (smart
contracts) with hosts for pricing, uptime commitments,
etc. Service Level Agreements (SLAs) are stored on the
Sia blockchain and automatically enforced by the
network.
29. Steemit
170
31. Theta
171
32. TokenTerminal
33. Truffle
172
This video covers:
1. Web Storage
2. Web Workers
3. Server-Sent Events
4. Hash calculations
5. Password Security using Salt & Pepper
6. Cryptographically strong pseudorandom number
generator (CSPRNG)
7. Encryption & Decryption
https://www.youtube.com/live/68u-GVvdbds?feature=
share&t=74
173
11
ChatGPT
Super Prompt
Templates
ChatGPT Super Prompt Templates
Here are some ChatGPT super prompt templates that
you can customize and use:
175
2. Building scalable decentralized applications (dApps)
176
4. Suggesting improvements to existing blockchain
systems
177
6. Choosing blockchain consensus mechanisms
178
8. Implementation of blockchain-based payment
systems
179
10. Design & implementation of blockchain-based
gaming systems
180
12. Simulating a Bitcoin node
181
12
Interview
Questions
12.1 Blockchain Basics
1. How would you explain blockchain technology to
someone without a technical background?
183
12.2 Blockchain APIs
1. Can you explain what a Blockchain API is and
how it differs from traditional APIs?
184
8. How do Blockchain APIs handle scalability and
efficiency issues, especially in systems with high
transaction volumes?
185
12.4 Node Maintenance &
Optimization
1. What are some key considerations for blockchain
data storage and management?
12.5 Bitcoin
1. Can you explain what Bitcoin is and how it differs
from traditional fiat currencies?
186
5. Can you explain the process of a Bitcoin
transaction from one wallet to another? What
role do private and public keys play in this?
12.6 Ethereum
1. Can you explain what Ethereum is and how it
differs from Bitcoin?
187
4. How does Ethereum's consensus mechanism
work?
12.7 Multichain
1. Can you explain what MultiChain is and how it
differs from Ethereum and Hyperledger?
188
3. What are some key features of MultiChain that
make it suitable for enterprise blockchain
applications?
190
12.9 Hyperledger
1. Can you explain what Hyperledger is and how it
differs from other blockchain platforms like
Ethereum?
192
13
Quiz
Questions
BEP-1. Which of these Blockchain performance
indicators represents the transactions per second that
a consensus algorithm can process?
194
BEP-4. Which of these Blockchain performance
indicators represents the ability for a network to
expand without degrading performance?
A. Layer-0 Blockchains
B. Layer-1 Blockchains
C. Layer-2 Blockchains
A. Blockchain Frameworks
B. Cosmos & Horizen
A. Layer-0 Blockchains
B. Layer-1 Blockchains
C. Layer-2 Blockchains
195
BEP-8. Which type of blockchain nodes enable faster
and cheaper transactions?
A. Cold nodes
B. Light nodes
C. Lightning nodes
A. True
B. False
A. Nodes
B. Smart contracts
196
BEP-12. In which type of Blockchain fork does each
node need to upgrade its software to be compatible
with the new processes?
A. Hard Fork
B. Soft Fork
A. Light nodes
B. Lightning nodes
A. Cold nodes
B. Lightning nodes
A. Blockchain Frameworks
B. Layer-2 Blockchains
197
BEP-16. Which of these consists of the hardware,
software, and networks that enable the functioning of a
blockchain?
A. Infrastructure Layer
B. User Interface Layer
A. Application Layer
B. User Interface Layer
A. Trusted
B. Trustless
198
BEP-20. Which of these enables fungible Ethereum
tokens to be re-used by other applications such as
wallets and decentralized exchanges?
A. ERC-20
B. ERC-721
A. ERC-918
B. ERC-1178
A. True
B. False
A. ERC-10
B. ERC-777
199
BEP-24. Which standard outlines a smart contract
interface that can represent any number of fungible
and non-fungible token types?
A. ERC-1203
B. ERC-1155
A. ERC-1178
B. ERC-1203
A. True
B. False
200
BEP-28. Which is a structure where every address gets
its own chain that only it can write to, and everyone
holds a copy of all of the chains?
A. Block-lattice
B. Proof of Zero
C. VeriBlock
A. Hashgraph
B. Magi's POS
C. Raft
A. Proof of Process
B. Proof of Stake Boo
C. Proof of Work
201
BEP-32. The goal of which of these blockchain attacks
is to perform a double spend?
A. 51% Attack
B. Sybil Attack
A. 51% Attack
B. Sybil Attack
A. 51% Attack
B. DDOS Attack
C. Sybil Attack
A. 51% Attack
B. DDOS Attack
C. Sybil Attack
A. 51% Attack
B. Eclipse Attack
202
14
Quiz
Answers
BEP-1: D BEP-2: A BEP-3: B
204
Credits
● Cover image: https://www.freepik.com
● https://blockchainblog.substack.com
● https://ethereum.org
● https://bitcoin.org
● https://blog.coinbase.com/a-simple-guide-to-the-
web3-developer-stack-8364b612d69c
● https://alchemy.com/blog/web3-stack
● https://en.bitcoin.it
● https://www.multichain.com
205