BL Mod3
BL Mod3
An ERC20 token is a standardized type of token used on the Ethereum blockchain. The
ERC20 standard defines a common set of rules that all fungible Ethereum tokens must follow,
allowing them to interact seamlessly with wallets, exchanges, and other smart contracts.
● Interoperable: Can be used across different platforms and dApps that support ERC20.
● Smart Contract-Based: Logic and data are stored on the Ethereum blockchain.
You need:
Install OpenZeppelin:
2
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
Explanation:
● initialSupply is the amount minted at deployment (in smallest unit, usually wei).
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Summary
Ste Action
p
1 Set up environment (Hardhat, MetaMask)
Let me know if you'd like a full working project example or to deploy your own test token!
4
1. Create
2. Freeze
3. Execute
4. Finalize
1. Create
2. Freeze
3. Execute
6
Participating nodes read contracts that are stored on the distributed ledger.
The integrity of a smart contract is verified by the authenticating nodes, and
the code is executed by the smart contract's interference engine (or by the
compiler). When the inputs for the execution from one party are received in
the form of coins (commitment to goods through coins), the interference
engine creates a transaction triggered by the met criteria.
Now the new transaction data is added to the blockchain and to ensure
fulfillment according to the agreed-upon terms in the Smart contract the
governing nodes now verify it again. 'Consensus mechanism' governs this
verification process.
4. Finalize
After a smart contract has been executed, the new states of all involved
parties are updated. Now the updated state information and resulting
transactions are put in the distributed ledger of the blockchain and the
consensus mechanism verifies that the assets transferred by the first party
have been received and unfreezes the assets for the receiving party.
The smart contract has completed the whole life cycle. During freezing,
execution, and finalization the sequence of transactions has been executed and
stored in the blockchain.
This type of smart contract is especially relevant in legal and real estate industries,
where trust and compliance are paramount. For example, a real estate transaction can
be facilitated using a smart legal contract, ensuring that the property title is
automatically transferred once payment is received.
Companies can use supply chain contracts to ensure the authenticity of products,
prevent counterfeiting, and streamline logistics.
Tokenization contracts
Tokenization contracts are integral to the creation and management of digital assets,
such as cryptocurrencies, security tokens, and non-fungible tokens (NFTs). These
contracts define the rules and properties of tokens, enabling their creation, transfer, and
management within the blockchain ecosystem.
For instance, NFT creators use tokenization contracts to define the unique properties
and ownership rules of digital collectibles.
These are just a few smart contract examples and the various types that have emerged
in the blockchain space. The flexibility and adaptability of smart contracts make them an
invaluable tool in multiple industries, revolutionizing the way agreements and processes
are handled.
Oracles provide a way for the decentralized Web3 ecosystem to access existing data
sources, legacy systems, and advanced computations. Decentralized oracle networks
(DONs) enable the creation of hybrid smart contracts, where onchain code and offchain
infrastructure are combined to support advanced decentralized applications (dApps) that
react to real-world events and interoperate with traditional systems.
MO
Types of Oracles
Input Oracles
9
The most widely recognized type of oracle today is known as an “input oracle,” which
fetches data from the real-world (offchain) and delivers it onto a blockchain network for
smart contract consumption. These types of oracles are used to power Chainlink Price
Feeds, providing DeFi smart contracts with onchain access to financial market data.
Output Oracles
The opposite of input oracles are “output oracles,” which allow smart contracts to send
commands to offchain systems that trigger them to execute certain actions. This can include
informing a banking network to make a payment, telling a storage provider to store the
supplied data, or pinging an IoT system to unlock a car door once the onchain rental
payment is made.
Cross-Chain Oracles
Another type of oracle are cross-chain oracles that can read and write information between
different blockchains. Cross-chain oracles enable interoperability for moving both data and
assets between blockchains, such as using data on one blockchain to trigger an action on
another or bridging assets cross-chain so they can be used outside the native blockchain
they were issued on.
Compute-Enabled Oracles
A new type of oracle becoming more widely used by smart contract applications are
“compute-enabled oracles,” which use secure offchain computation to provide decentralized
services that are impractical to do onchain due to technical, legal, or financial constraints.
This can include using Chainlink Automation to trigger the running of smart contracts when
predefined events take place, computing zero-knowledge proofs to generate data privacy,
or running a verifiable randomness function to provide a tamper-proof and provably fair
source of randomness to smart contracts.
10
1. Nonce
2. Gas Price
3. Gas Limit
4. To (Recipient)
5. Value
6. Data
Let’s now go into detail for the main terms you asked about:
1. Transaction Nonce
✅ What is it?
11
● A nonce is an integer (starting from 0) that increases with every transaction sent from an
Ethereum address.
● It ensures each transaction is unique and executed only once, in correct order.
💡 Why it matters:
🧠 Example:
If your wallet has already sent 5 transactions, the next transaction's nonce must be 5.
⛽ Gas
● Every operation (e.g., add, store, transfer) on the Ethereum Virtual Machine (EVM)
costs a certain amount of gas.
💰 Gas Price
● The fee per unit of gas, measured in gwei (1 gwei = 10⁻⁹ ETH).
● A higher gas price means faster transaction processing (miners prefer higher fees).
● Protects users from bugs or unexpected behavior (like infinite loops in contracts).
Example:
✅ What is it?
● It can be:
🧠 Example:
0x742d35Cc6634C0532925a3b844Bc454e4438f44e
4. Value
✅ What is it?
Use cases:
13
🧠 Example:
value = 1000000000000000000 wei = 1 ETH
5. Data
✅ What is it?
● Most often used to call functions on smart contracts or deploy new contracts.
Format:
● Encoded in hexadecimal.
0xa9059cbb000000000000000000000000RecipientAddress...000000000000000000000000000
000000Amount
In Summary
14
Field Description
Gas Limit Max computation allowed for the transaction. Prevents excessive
usage.
Gas Price Fee per gas unit. Higher price = faster confirmation.
Recipient Target address for the transaction. Could be a user or smart contract.
Value Amount of ETH (in wei) to send. Can be 0 for contract calls.
If you want, I can show you an actual decoded Ethereum transaction from Etherscan, or help
you build one manually.
A standard for
A standard for non-fungible
Definition fungible tokens on
tokens (NFTs) on Ethereum.
Ethereum.
They're divisible;
ERC20 tokens can be
divided in a number of
Divisibility They're not divisible at all.
ways. Even sharing
0.1 % of the token is
possible.
18
1. The value
doesn't
1. The value
fluctuate,
fluctuates
since they're
according to rarity
not unique.
and uniqueness.
Fluctuation 2. Requires
2. Requires unique
one
smart contracts for
common
each token.
smart
contract.
In ERC20 standards,
The values of each token are
Values there's no difference
different.
in values.
IPFS stands for InterPlanetary File System. It is a peer-to-peer distributed file storage
system that allows files to be stored and shared across a decentralized network. In the context
of Ethereum, IPFS is used to store large files off-chain, while only the file’s hash (or link)
is stored on-chain.
● Storing data on-chain costs gas, which scales with file size.
So instead of storing files like images, documents, or metadata on Ethereum, developers use
IPFS to store the file off-chain and store a reference (hash) to the file on Ethereum.
21
● IPFS generates a unique hash (CID) for the file based on its content.
● Smart contracts or dApps can use this hash to fetch the file from IPFS later.
3. File Retrieval
● Anyone can access the file using the IPFS hash via an IPFS gateway (e.g.,
https://ipfs.io/ipfs/<CID>).
🎯 Purpose:
To store and distribute data and dApp code in a decentralized way, eliminating reliance on
centralized servers.
3. Content Addressing: Each chunk is given a unique hash, just like in IPFS.
4. Retrieval: The user can retrieve the file by its hash; Swarm finds and reassembles all
the pieces.
5. Incentives: Nodes are rewarded for storing and serving data using the BZZ token
(Swarm's native token).
1. Remix IDE
● Features:
Use Case: Try out contracts quickly, learn Solidity, debug small scripts.
2. Truffle Framework
● Language: JavaScript/TypeScript
● Features:
Use Case: Building production-level dApps; testing and deploying in controlled environments.
3. Hardhat
● Features include:
Use Case: Preferred by modern dApp developers for flexibility and plugin ecosystem.
4. Ganache
● Provides:
○ Easy debugging
5. MetaMask
○ Sign transactions
Summary Table
Tool Purpose Best For
Let me know if you want help setting up a real Solidity project with any of these tools!
● Developers don’t need to write custom code to handle each new token.
Example: MetaMask and Uniswap support thousands of ERC20 tokens out of the box.
○ In-game currency
26
○ Loyalty points
● Most DeFi protocols (like Uniswap, Aave, Compound) rely on ERC20 tokens for:
○ Lending/borrowing
○ Trading/swapping
○ Yield farming
○ Staking
● ERC20 tokens are widely used for Initial Coin Offerings (ICOs) and Token Generation
Events (TGEs).
● You can write smart contracts that interact with ERC20 tokens to:
○ Trigger rewards
27
○ Automate payments
6. Cross-Platform Utility
● ERC20 tokens can be bridged to other blockchains, increasing their utility beyond
Ethereum.
Summary Table
Use Case How ERC20 Helps
Syllabus
28
The concept of a permissionless blockchain is central to how public blockchain networks like
Bitcoin and Ethereum operate. Let’s break it down clearly:
Open Participation Anyone can join the network as a user, miner, validator, or developer.
Transparent All transactions are visible to everyone on the network (public ledger).
Censorship- No one can prevent or block valid transactions from being processed.
Resistant
● Ethereum: Anyone can deploy smart contracts, create tokens, or validate blocks (on
Proof of Stake).
How It Works
1. Consensus Mechanisms
● Nodes in the network reach agreement (consensus) without central coordination using
algorithms like:
2. Incentives
Let me know if you’d like to see real-world applications that rely on permissionless blockchain
networks!
Mining in Ehtereum
Before Ethereum transitioned to Proof of Stake (PoS) in September 2022 through "The
Merge", Ethereum used a Proof of Work (PoW) consensus mechanism, similar to Bitcoin.
Here's a detailed explanation of how mining worked on Ethereum when PoW was in use:
● Validating transactions
Miners competed to solve a computational problem. The first one to solve it would:
Block Reward Miners earned 2 ETH per block (as of before The Merge), plus
transaction fees.
Miners picked pending transactions from the network and organized them into a potential block.
2. Hash Puzzle
● The miner tried to find a nonce that, when combined with block data and hashed
through Ethash, produced a hash below a target difficulty value.
3. Block Submission
● Once a valid nonce was found, the miner broadcasted the block to the network.
● Other nodes verified the block’s correctness and added it to their chain.
4. Reward
Why?