Category: learn

  • Decentralized Finance Part 4: Real World Assets Meet DeFi

    Decentralized Finance Part 4: Real World Assets Meet DeFi

    What if you could earn rent from a house you don’t own, in a country you’ve never been to, using an app on your phone?

    That’s the power of real-world assets in DeFi.

    What Are Real World Assets (RWA)?

    Real World Assets are things that exist outside the blockchain.

    Examples:

    • Houses
    • Company shares
    • Government bonds
    • Invoices
    • Art or collectibles

    These things are now being linked to DeFi through tokenization.

    This means creating a digital version of a real asset, which can then be traded or used inside smart contracts.

    Why Should We Care?

    Tokenized real world assets open up new investment opportunities, making high-value assets more accessible to everyone. They bring much-needed liquidity to traditionally hard-to-sell assets, allowing for quicker transactions. The transparency and security of blockchain technology reduce fraud and build trust. Plus, integrating RWAs with DeFi creates innovative financial products and services, building a more inclusive, efficient, and transparent financial system for all, and more…

    RWA Needs an On-Chain Connection

    Real world assets live outside the blockchain.

    To use them inside DeFi, we need a way to connect them to smart contracts.

    This means creating a bridge between the physical world and the digital one.

    Someone needs to verify the asset, hold it safely, and create a digital version of it on-chain.

    That digital token is what DeFi apps can then use for trading, lending, borrowing, or earning.

    Without this connection, real-world assets cannot interact with DeFi tools. The token must reflect the real thing clearly and must be backed by trust.

    You Can Make These TODAY!

    The exciting part is that tokenizing real-world assets isn’t just for big corporations or tech gurus. With the right platforms and knowledge, individuals and businesses can also participate in creating these digital representations of physical assets today. The process generally involves a few key steps. First, the real-world asset needs to be legally verified and appraised to determine its value and ownership. This is a crucial step to ensure that the digital token accurately reflects the physical asset. Once verified, the asset is then ‘tokenized’ on a blockchain.

    This means a smart contract is created that represents the asset, and digital tokens are issued. These tokens can then be bought, sold, or traded on various blockchain platforms. While it might sound complex, many platforms are emerging that simplify this process, making it more accessible for a wider audience. This means that the potential for bringing real-world value onto the blockchain is immense, and it’s happening right now, opening up new avenues for investment and ownership.

    Key Benefits of RWA + DeFi

    1. New Investment Opportunities: Tokenized real-world assets make high-value assets (like real estate, art, etc.) more accessible to everyone, lowering the barrier to entry for investments.
    1. Increased Liquidity: Traditionally illiquid assets can be bought and sold almost instantly on a global market, allowing for quicker transactions and easier access to asset value.
    1. Enhanced Transparency and Security: Blockchain technology ensures that every transaction is recorded on an immutable ledger, reducing fraud and increasing trust in asset ownership and transfer.
    1. Innovative Financial Products: The integration of RWAs with DeFi platforms enables new financial services, such as using tokenized real estate as collateral for loans or participating in decentralized exchanges with real-world backed assets.

    Popular RWA Projects in DeFi

    1. Centrifuge – Brings real-world loans (like invoices) to DeFi
    1. Goldfinch – Offers loans to real businesses in emerging markets
    1. Maple – Lets institutions borrow on-chain
    1. Ondo – Tokenizes US Treasuries for yield

    Challenges to Watch

    • Legal rules are not clear yet
    • Need for trusted middlemen to hold the real asset
    • Hard to scale across countries
    • Price feeds and real-world data must be accurate

    Final Thoughts

    Real World Assets will bring real growth to DeFi.

    They connect blockchain to the world we live in.

    And they give DeFi a chance to solve real problems, not just trade tokens.

  • Decentralized Finance Part 3: The Complete Guide to Stablecoins

    Decentralized Finance Part 3: The Complete Guide to Stablecoins

    The Problem That Started It All

    Imagine you bought a cup of coffee with Bitcoin six months ago. Back then, it cost you 0.0001 BTC. Today, that same amount of Bitcoin could buy you either half a cup or three cups, depending on Bitcoin’s wild price swings. But if you paid with dollars six months ago and pay with dollars today, you’d pay roughly the same amount. This is the fundamental problem that stablecoins solve.

    What Are Stablecoins?

    Most people think stablecoins are simply “non-volatile crypto assets.” This definition is wrong.

    The correct definition: A stablecoin is a crypto asset whose buying power fluctuates very little relative to the rest of the market.

    The keyword here is “buying power.” It’s not about price stability, it’s about purchasing power stability. A stablecoin should let you buy roughly the same amount of goods today as you could yesterday, next week, or next month.

    Why Do We Care About Stablecoins?

    Money serves three critical functions, and understanding these explains why stablecoins matter:

    1. Store of Value

    Money should preserve your wealth over time. When you save money in a bank or invest in stocks, you expect it to maintain its purchasing power. Volatile assets like Bitcoin fail at this because your wealth can disappear overnight.

    2. Unit of Account

    Money should help us measure how valuable something is. We price Bitcoin in dollars, not the other way around, because Bitcoin’s constant price changes make it a poor measuring stick. Nobody wants to price their business in Bitcoin when it could be worth 50% less tomorrow.

    3. Medium of Exchange

    Money should facilitate transactions. While you can technically buy groceries with Bitcoin, most people won’t because they don’t want to spend an asset that might double in value next week.

    The Web3 Money Problem: Ethereum works great as a store of value and medium of exchange, but fails as a unit of account due to its volatile nature. We need Web3 money that can do all three functions reliably

    Categories and Properties of Stablecoins

    1. Relative Stability: Pegged/Anchored or  Floating

    Pegged  Stablecoins: These are tied to another asset’s value. Most popular stablecoins fall into this category:

    • Tether (USDT): 1 USDT = 1 USD
    • USD Coin (USDC): 1 USDC = 1 USD

    Floating Stablecoins: These maintain stable buying power without being tied to any specific asset. Think of it this way: if you could buy 10 apples with 10 dollars five years ago, but today you can only buy 5 apples with 10 dollars due to inflation, a floating stablecoin would adjust so you can still buy 10 apples with the same amount.

    Anchored Stablecoins: These are pegged to a specific reference point that moves over time. Think of it like measuring ocean levels, where the anchor point itself changes but the relationship remains stable.

    2. Stability Method: Governed vs Algorithmic

    This refers to who or what controls the minting and burning of stablecoins to maintain their peg.

    Governed Stablecoins: Humans or organizations decide when to create or destroy tokens. These are typically centralized:

    • A government entity
    • A company (like Circle for USDC)
    • A decentralized autonomous organization (DAO)

    Algorithmic Stablecoins: Smart contracts automatically mint and burn tokens based on predetermined rules. No human intervention required:

    • DAI (partially algorithmic)
    • FRAX
    • RAI
    • UST (failed example)

    3. Collateral Type: Endogenous vs Exogenous

    This describes what backs the stablecoin’s value.

    Exogenous Collateral: Backed by assets outside the stablecoin’s ecosystem:

    • USDC is backed by US dollars
    • DAI is backed by ETH, USDC, and other external assets

    If these stablecoins fail, their underlying collateral (dollars, ETH) continues to exist and function.

    Endogenous Collateral: Backed by assets within the same ecosystem:

    • UST was backed by LUNA tokens
    • If UST failed, LUNA would fail too (which actually happened)

    The relationship creates a reflexive loop where the stablecoin and its collateral depend on each other for value.

    The Endogenous Dilemma

    Endogenous collateral sounds risky, so why use it at all?

    The Answer: Capital Efficiency

    With exogenous stablecoins like USDC, you need to over-collateralize. To mint $100 worth of DAI, you might need to deposit $150 worth of ETH. This ties up a lot of capital.

    Endogenous stablecoins can theoretically operate with zero external collateral because they’re backed by their own ecosystem. This makes them highly capital efficient but also highly risky.

    Check out these visuals to understand how some of the most well-known stablecoins are built and how they work

    (DAI StableCoin)

    ( USDC StableCoin)

    (RAI StableCoin)

    What Stablecoins Really Do

    Beyond just maintaining stable value, stablecoins serve as:

    Financial Infrastructure: They enable DeFi protocols to function with predictable unit pricing.

    Bridge Between Traditional and Crypto: They allow seamless movement between fiat and crypto worlds.

    Yield Generation: Many stablecoins can be staked or lent to earn interest.

    Global Access: They provide dollar-equivalent access to people in countries with unstable currencies.

    Which Stablecoins Are Good?

    For Safety and Reliability:

    • USDC: Highly regulated, transparent reserves
    • DAI: Decentralized, over-collateralized, battle-tested

    For Innovation:

    • RAI: Truly algorithmic, not pegged to fiat
    • FRAX: Hybrid model balancing efficiency and stability

    Trade-offs to Consider:

    • Centralized stablecoins (USDC) offer stability but can be frozen or regulated
    • Decentralized stablecoins (DAI, RAI) offer censorship resistance but may have slight fees and complexity
    • Algorithmic stablecoins offer capital efficiency but carry higher risks

    The Future of Stablecoins

    The stablecoin landscape continues evolving as projects balance three competing priorities:

    1. Stability – Maintaining purchasing power
    2. Decentralization – Avoiding central points of failure
    3. Capital Efficiency – Maximizing utility of locked assets

    The most successful stablecoins will likely be those that find the optimal balance between these three factors while serving the core functions of money in the digital age.

    Before you use or build with stablecoins, take the time to understand how they’re designed. The more you know, the better decisions you’ll make in the Web3 world.

  • Decentralized Finance Part 2: Money Markets

    Decentralized Finance Part 2: Money Markets

    Banks have controlled lending and borrowing for centuries. They decide who gets loans, set the interest rates, and hold all the power. If your credit score isn’t perfect or you don’t have the right paperwork, you’re out of luck.

    DeFi Money Markets flip this system completely upside down.

    No credit checks. No paperwork. No waiting weeks for approval.

    Just deposit your crypto as collateral, and borrow instantly. The smart contract handles everything else.

    What Are DeFi Money Markets?

    DeFi money markets are lending platforms built on smart contracts.

    They allow users to:

    • Lend crypto and earn interest – Deposit your tokens and get paid for lending them out
    • Borrow crypto and pay interest – Put up collateral and borrow different tokens

    The most popular platforms include Aave, Compound, and others.

    But here’s the catch:

    You can’t borrow unless you first deposit something valuable.

    This is called collateral.

    Traditional Borrowing vs DeFi

    In traditional loans, you get money based on:

    • Your salary
    • Credit score
    • Personal background

    In DeFi, none of that matters.

    The only thing that matters is how much you deposit as collateral.

    How Collateral-Based Borrowing Works

    The Collateral System

    In DeFi, collateral is your security deposit. It’s like leaving your car keys with a friend when you borrow their bike. If you don’t return the bike, they keep your keys.

    Here’s a simple example:

    • You deposit 1,000 USDC as collateral
    • You can then borrow 800 DAI (or ETH worth $800)
    • You can’t borrow more than you deposited
    • Your collateral stays locked until you repay the loan

    DeFi Money Markets Glossary

    Collateral

    The crypto you deposit as security to borrow other tokens. If you deposit 1 ETH to a protocol, your collateral is 1 ETH.

    Loan-to-Value (LTV) Ratio

    LTV determines how much you can borrow compared to your collateral value. It’s expressed as a percentage.

    Example with 75% LTV:

    • You deposit 1 ETH worth $1,000 as collateral
    • You can borrow up to 0.75 ETH worth of other tokens (or $750 worth)
    • The protocol keeps 25% as a safety buffer

    Different tokens have different LTV ratios based on their stability and risk.

    The Liquidation Threshold

    Liquidation happens when your borrowed amount becomes too risky compared to your collateral. It’s the protocol’s way of protecting itself and other users.

    Common triggers:

    • Your collateral drops in value (ETH price falls)
    • Your borrowed asset rises in value (borrowed token pumps)
    • You borrow too close to your limit

    How Liquidation Works

    When you cross the liquidation threshold:

    1. Liquidators step in – These are users who “buy” your debt
    2. You pay a penalty – Usually 5-10% of your collateral value
    3. Your collateral gets sold – To cover the borrowed amount
    4. You keep the rest – Any remaining collateral after paying debt and penalty

    The warning system: Most protocols show you a “health factor” that warns you before liquidation happens.

    Annual Percentage Yield (APY)

    The yearly return on your investment, including compound interest. If you earn 10% APY, your money grows by 10% over one year with compounding.

    Annual Percentage Rate (APR)

    The yearly cost of borrowing without compound interest. If you pay 8% APR, you pay 8% interest over one year on the original loan amount.

    Receipt Token

    A special token you receive when depositing into a protocol. It’s like a receipt that proves you deposited funds. These tokens are minted when you deposit and burned when you withdraw.

    Reserve/Underlying Asset

    The actual token you deposited into the protocol. For example, if you deposit ETH into AAVE, WETH is the underlying token, and you receive aWETH receipt tokens.

    Key Benefits of DeFi Money Markets

    For Lenders:

    • Earn passive income on idle crypto
    • No minimum deposit requirements
    • Withdraw anytime (subject to liquidity)
    • Transparent interest rates

    For Borrowers:

    • No credit checks or paperwork
    • Instant loan approval
    • Keep your crypto exposure while borrowing
    • Access to leverage trading strategies

    AAVE: The largest lending protocol with innovative features like flash loans and rate switching.

    Compound: Pioneer in DeFi lending with simple, reliable mechanics.

    MakerDAO: Focused on DAI stablecoin creation through collateralized debt positions.

    Conclusion

    DeFi money markets represent a fundamental shift in how we think about lending and borrowing. They remove gatekeepers, reduce costs, and provide global access to financial services.

    The power is now in your hands. No banker can reject your loan application. No credit agency can block your access. Just you, your crypto, and the smart contract.

    But with great power comes great responsibility. Understanding collateral, liquidation, and risk management is essential before diving in.

  • Decentralized Finance Part 1: Understanding DEXs and AMMs

    Decentralized Finance Part 1: Understanding DEXs and AMMs

    A few years ago, if you wanted to buy or sell crypto, you had to go through a central exchange. You’d sign up, verify your identity, and trust the platform to keep your money safe.

    Then came Decentralized Exchanges (DEXs), a new way to trade crypto without giving up control.

    No sign-ups. No middlemen. No waiting for someone on the other side.

    Just you, a wallet, and a smart contract.

    This is the revolutionary promise of Decentralized Finance (DeFi), where smart contracts handle everything automatically. Today, we’ll explore the foundation of DeFi: Decentralized Exchanges (DEXs) and the magic behind them

    What is a Decentralized Exchange (DEX)?

    A Decentralized Exchange (DEX) lets you trade one token for another, directly from your wallet. There’s no company holding your money. Instead, smart contracts handle everything.

    You connect your wallet. You choose what you want to swap. And the trade happens instantly.

    How Does a DEX Actually Work?

    Let’s break down the key components that make DEXs possible:

    1. Liquidity Pools

    A liquidity pool is like a jar filled with two tokens. For example:

    • 50 ETH and
    • 10,000 DAI

    People add their tokens to these pools. These people are called liquidity providers, and they earn small fees from every trade that happens.

    2. Swapping

    You want to swap your DAI for ETH?

    The smart contract pulls ETH from the pool and adds your DAI to it.

    The price changes based on how much you take and how much you give.

    3. Automated Market Maker (AMM): The Price Calculator

    Here’s where it gets interesting. Instead of matching you with another trader (like in traditional markets), an AMM uses a mathematical formula to determine prices instantly. It’s like having a calculator that always knows the fair price based on how much of each token is in the pool.

    4. Small Fees, Big Rewards

    Every trade pays a small fee (typically 0.3%). This fee gets distributed among all the people who provided liquidity to that pool. It’s like getting a cut of every transaction just for helping keep the marketplace running.

    Understanding Liquidity and Why It Matters

    What is Liquidity? Liquidity is simply having enough tokens in a pool to make trading smooth and efficient. Think of it like having enough cash in your wallet to buy coffee without needing to break a $100 bill.

    Why Do We Need It? Without enough liquidity, strange things happen:

    • Trades become slow and expensive
    • Prices swing wildly with small purchases
    • Large trades become nearly impossible

    Who Benefits?

    • Traders get fast, reliable swaps
    • Liquidity providers earn passive income from fees
    • The entire ecosystem stays healthy and functional
    1. PancakeSwap – Built on Binance Smart Chain. Fast and great for beginners.
    2. SushiSwap – Available on many chains. It rewards people who add liquidity.

    There are many more. Each one has its own pools, tokens, and features.

    DEX vs CEX: Choose Your Adventure

    Centralized Exchange (CEX):

    • Requires account creation and identity verification
    • Company holds your funds
    • Easy to use with familiar interfaces
    • Customer support available

    Decentralized Exchange (DEX):

    • No signup required
    • You always control your funds
    • More privacy and anonymity
    • Full responsibility for your own security

    The Bottom Line: Want complete control and privacy? Go with a DEX. Prefer simplicity and support? Choose a CEX.

    How Automated Market Makers Work

    An Automated Market Maker (AMM) is a smart contract that lets you swap tokens without needing someone else on the other side.

    Let’s Break Down the Formula

    X × Y = K

    • X = Amount of Token 1 in the pool
    • Y = Amount of Token 2 in the pool
    • K = A constant number that never changes

    Think of K as the pool’s “balance point.” No matter how much trading happens, the formula ensures X × Y always equals K.

    A Real-World Example

    Let’s say we have a pool with:

    • 50 ETH (Token 1)
    • 10,000 DAI (Token 2)
    • K = 50 × 10,000 = 500,000

    Now imagine you want to buy 1 ETH using DAI.

    After your trade:

    • ETH remaining = 49 (you took 1 ETH out)
    • To keep K = 500,000, we need: 49 × Y = 500,000
    • Y = 500,000 ÷ 49 = 10,204.08 DAI

    Since the pool started with 10,000 DAI and needs 10,204.08 DAI after your trade, you must add 204.08 DAI to buy 1 ETH.

    The price was calculated automatically by the formula, not by a person!

    Why Prices Change as You Trade

    Here’s where it gets interesting. The more ETH you try to buy, the more DAI you need to add to keep K constant. This makes each additional ETH more expensive.

    Example:

    • Buying 1 ETH costs ~204 DAI
    • Buying 2 ETH would cost even more per ETH
    • Buying 10 ETH would be extremely expensive per ETH

    This price increase is called “slippage,” and it’s completely normal in AMMs. It prevents any single person from draining the entire pool

    This price jump is called slippage, the more you buy, the more you pay.

    AMM vs Order Book

    • Order Book (used by CEX): Buyers and sellers agree on a price
    • AMM (used by DEX): The price is decided by a formula

    In AMMs, you don’t wait for someone to match your trade.

    The pool is always ready, the formula handles everything.

    Key Takeaways

    1. DEXs eliminate middlemen – You trade directly through smart contracts
    2. Liquidity pools are the foundation – They provide the tokens needed for smooth trading
    3. AMMs use simple math – The X × Y = K formula determines all prices
    4. Everyone benefits – Traders get instant swaps, providers earn fees
    5. You stay in control – Your funds never leave your wallet

    In Part 2, we’ll explore money markets

  • Gas Optimization Part 4: Solidity Tips for Cheaper Contracts

    Gas Optimization Part 4: Solidity Tips for Cheaper Contracts

    Every line of your smart contract costs something.

    Some lines cost more than others.

    In this part of our gas saving series, we’ll explore how to write smarter Solidity code that keeps your contract lean and efficient.

    Here are six simple and practical ways to reduce gas costs while writing Solidity smart contracts.

    1. Use payable Only When Needed, But Know It Saves Gas

    In Solidity, a function marked payable can actually use slightly less gas than a non-payable one.

    Even if you’re not sending ETH, the EVM skips some internal checks when the function is marked payable.

    See this example:

    function hello() external payable {}    // 21,137 gas

    function hello2() external {}           // 21,161 gas

    That tiny difference may not seem like much, but across thousands of calls, it adds up.

    • Only use payable when your function is actually meant to accept ETH

    2. Use unchecked for Safe Arithmetic When You’re Sure

    Since Solidity 0.8.0, all arithmetic operations automatically check for overflows and underflows. While this makes contracts safer, it also uses extra gas. When you’re certain that overflow won’t occur, you can use the unchecked keyword to skip these safety checks.

    uint256 public myNumber = 0;

    function increment() external {

    unchecked {

    myNumber++;

    }

    }

    Gas used: 24,347 (much cheaper than using safe math)

    Warning: Use unchecked carefully. Only when you’re confident there’s no risk of overflow.

    3. Turn On the Solidity Optimizer

    The Solidity Optimizer is like a smart helper that cleans up and tightens your compiled bytecode.

    It does not change how your contract works, but it removes waste and makes it cheaper to run.

    If you’re using tools like Hardhat or Remix, always enable the Optimizer before deploying to mainnet.

    4. Use uint256 Instead of Smaller Integers (Most of the Time)

    Smaller types like uint8 or uint16 might look more efficient, but they can cost more gas during execution.

    That’s because the EVM automatically converts them to uint256 behind the scenes.

    So, if you’re not tightly packing them in a struct for storage savings, just use uint256.

    Use smaller types only in structs when trying to save storage space.

    5. Understand Storage Costs: Read + Write Costs Almost Same as Write

    Storage operations are expensive. But here’s something surprising:

    Reading a storage variable before writing to it doesn’t cost much more than writing directly.

    Example:

    • Read + Write = 2,100 (read) + 20,100 (write) = 22,200 gas
    • Write only = 22,100 gas

    That means if your code needs to read before writing, it’s okay, you are not losing much.

    Plan your storage usage wisely. Reuse variables and avoid unnecessary writes.

    Reference: https://ethereum.github.io/yellowpaper/paper.pdf

    6. Use < Instead of <= in Comparisons

    When comparing numbers, use < instead of <=.

    Why? Because:

    • < needs just one check
    • <= takes two checks (a comparison and an extra step to flip the result)

    Fewer steps mean lower gas usage.

    Example:

    for (uint i = 0; i < limit; i++) {

    }

    This small change saves gas on every loop iteration and comparison operation.

    Conclusion

    Gas optimization is about understanding how the EVM works and making informed decisions about your code structure. Each of these techniques might seem to save small amounts of gas individually, but combined and applied across a large contract, they can result in significant cost savings.

    Remember: Always test your optimizations thoroughly. Sometimes gas savings come at the cost of code readability or safety. Strike the right balance for your specific use case.

    Key Takeaways:

    1. Use payable functions when appropriate
    2. Apply unchecked carefully for safe arithmetic
    3. Enable the Solidity optimizer
    4. Prefer uint256 for most variables
    5. Understand storage access patterns
    6. Choose efficient comparison operators

    By implementing these strategies, you’ll create contracts that not only work well but also cost less to deploy and interact with, making them more accessible to users and more profitable for developers.

  • Gas Optimization Part 3: The Foundation of Gas in Solidity and Smart Contract Efficiency

    Gas Optimization Part 3: The Foundation of Gas in Solidity and Smart Contract Efficiency

    You just deployed a smart contract, and it’s costing 98 gas to run a function that does nothing. Literally.

    See for yourself, Why?

    Because even doing “nothing” on Ethereum still means something to the Ethereum Virtual Machine (EVM).

    Welcome to Part 3 of our gas optimization series, where we will look at how gas really works behind the scenes and how you can make your Solidity smart contracts use less gas by removing anything that’s not needed.

    The Building Blocks: OPCODEs Are the DNA of Ethereum

    In Solidity, saving on gas is like saving fuel in your car. To do that, you need to know about OPCODEs – the basic commands that tell Ethereum what to do. They’re the ABCs of Ethereum’s language.

    When you write Solidity code, it doesn’t run directly on the Ethereum network. Instead, it gets compiled into a set of OPCODEs that the Ethereum Virtual Machine (EVM) can understand and execute. Think of it like translating English into machine language that computers can process

    What Are OPCODEs?

    OPCODEs are low level instructions that perform specific operations:

    Arithmetic Operations: ADD, SUB, MUL, DIV for mathematical calculations

    Memory Operations: MLOAD, MSTORE for temporary data storage

    Storage Operations: SLOAD, SSTORE for permanent blockchain storage

    Program Flow: JUMP, JUMPI for conditional logic.

    Cryptographic Functions: SHA3, ECRECOVER for security operations

    Contract Interactions: CALL, DELEGATECALL for inter-contract communication

    And here’s the catch:

    Each OPCODE consumes gas, and some cost way more than others.

    Pro Tip:

    You can see the full list of OPCODE gas costs here: ethereum.org/en/developers/docs/evm/opcodes

    The Secret Code: Function Selectors

    Here’s something that might surprise you: when you compile your Solidity code into bytecode, the names of your functions don’t actually show up in the final assembly output. Instead, what ends up on the Ethereum network is something like a secret code called function selectors

    How Function Selectors Work

    Function selectors are created by taking the first four bytes of the hash of the function’s signature. Let’s look at a real example:

    function doNothig() external pure {}

    After compilation, this becomes:

    46aad107

    So when someone sends a transaction to your contract, they don’t send the name doNothig(),they send the selector 0x46aad107.

    That’s how the EVM knows which function to run, without storing long names on-chain.

    Gas Optimization Tips Every Developer Should Know

    1. Keep It Light

    The less code you deploy, the less gas you’ll use during deployment. Think of it as packing light for a flight – every extra byte costs money.

    Code size optimization strategies:

    • Remove unnecessary functions and variables
    • Use libraries for common operations instead of duplicating code
    • Implement proxy patterns for upgradeable contracts
    • Strip out debugging code and comments in production

    Real impact: A 1KB reduction in contract size saves approximately 200,000 gas units during deployment

    2. Choose Wisely: OPCODE Selection

    Certain commands are cheaper than others. Picking the right ones is like choosing a budget airline over a luxury carrier.

    Cost-effective choices:

    • Some instructions (like ADD) cost less than others (like SSTORE).
    • Store fewer variables
    • Avoid unnecessary require checks
    • Minimize state changes

    3. Pack Data Tight: Transaction Data Optimization

    The more data you send in a transaction, the more you spend. Keep your transaction data lean.

    Data packing techniques:

    • Use struct packing to fit multiple variables in single storage slots
    • Compress arrays and use fixed-size arrays when possible
    • Batch multiple operations to reduce transaction overhead
    • Use events instead of storage for data that doesn’t need to be queried on-chain

    4. Minimize Memory Use

    Memory is temporary, but still costs gas.

    Avoid creating new memory variables when not required.

    Use calldata instead of memory for function inputs when possible

    5. Be Smart About Storage

    Storage is the most expensive operation.

    • Only write to storage if you must
    • Use events to log non-critical data instead of storing it
    • Don’t overwrite storage values unless necessary

    Every time you write to SSTORE, you’re paying a premium.

    The Compound Effect

    A little bit of gas saved on every transaction can add up to significant savings over time. If your contract processes 1,000 transactions per day and you save 500 gas per transaction, that’s 500,000 gas units daily – potentially saving hundreds of dollars monthly at current gas prices.

    Understanding OPCODEs and function selectors is just the beginning. In Part 4, we’ll explore advanced Solidity techniques that can dramatically reduce gas consumption

  • Gas Optimization Part 2: Timing Strategies and Batch Processing

    Gas Optimization Part 2: Timing Strategies and Batch Processing

    You’ve learned what gas fees are and how they’re calculated. Now comes the practical part: how to actually save money on every transaction you make. The difference between a novice and an expert Ethereum user often comes down to understanding when and how to execute transactions efficiently.

    Haven’t read Part 1 yet? Check out our introduction to gas fees and how they work to understand the fundamentals before diving into these optimization strategies.

    Let’s explore the proven strategies that can cut your gas costs by 50-90% without compromising transaction security or speed

    Strategy 1: Master the Art of Timing

    Weekends: Saturday and Sunday typically see 20-30% lower gas fees as business activity decreases.

    Off-peak hours: Between 2 AM and 6 AM UTC, when both American and European users are asleep, gas prices often drop significantly.

    Avoid these high-traffic periods:

    • NFT mint launches
    • Major DeFi protocol updates
    • Market crash periods (panic selling drives up demand)
    • Weekday mornings (8-10 AM UTC)

    You can use trackers like:

    Pro tip: Set up gas price alerts on your phone. When prices drop below your target threshold, that’s your window to execute pending transactions.

    Strategy 2: Batch Processing

    Why send 10 separate transactions…

    When you can send one batch?

    Batching reduces overhead, saves time, and lowers gas.

    Let’s explore 3 Ethereum standards that enable powerful batching:

    1) ERC-3005: Batched Meta Transactions – https://eips.ethereum.org/EIPS/eip-3005

    This standard lets users combine multiple actions into one meta transaction.

    Example:

    1. Approve token
    2. Swap on DEX
    3. Send output to wallet

    All in one call, reducing gas and relayer fees.

    Great for:

    1. Wallet apps
    2. Gasless UX
    3. Relayer-backed platforms

    2) ERC-7821: Minimal Batch Executor –  https://eips.ethereum.org/EIPS/eip-7821

    This one’s about delegations and shared execution.

    Think of it like batching multiple on-chain delegations, such as:

    • Voting
    • Staking
    • DAO participation

    With atomic execution, if one part fails, nothing gets through so it keeps safe and predictable.

    Perfect for:

    • DAO tools
    • Governance app
    • Delegation-heavy protocols

    Example scenario: You want to withdraw from a liquidity pool, swap the tokens, and deposit them into a yield farming protocol. ERC-7821 ensures all these operations happen atomically, preventing scenarios where only part of your strategy executes

    3) ERC-4393: Batch Micropayments – https://eips.ethereum.org/EIPS/eip-4393

    When you need to make multiple small payments, ERC-4393 shines. This standard enables multiple tips or payments in a single transaction call.

    Use case: Tipping multiple content creators or making several small purchases. Instead of paying gas fees for each micropayment, you pay once for the entire batch

    Strategy 3: Wait for gas to go down

    Gas prices go up and down every twelve seconds based on how congested Ethereum is. When gas prices are high, waiting just a few minutes before making a transaction could see a significant drop in what you pay.

    Strategy 4: Use Layer 2 Solutions

    Layer 2 solutions like zkSync, Arbitrum, and Optimism reduce gas fees by up to 95%. By bundling a large number of transactions together, these solutions reduce the number of on-chain transactions.

    Popular options:

    • Arbitrum
    • Optimism
    • Base
    • Polygon (PoS)

    Many dApps are now L2-ready. Just bridge your ETH once, and you’re good to go.

    Wrap-up

    Ethereum gas fees aren’t going away, but you can outsmart them with:

    1. Good timing
    2. Layer 2 networks
    3. Batched transactions using ERC-3005, ERC-7821, and ERC-4393
    4. Wait for the gas to go down

    What’s next?

    While timing and batching strategies can dramatically reduce your transaction costs, the next frontier in gas optimization lies in smart contract efficiency. In Part 3, we will explore advanced Solidity techniques that developers use to minimize gas consumption at the code level.

  • Gas Optimization Part 1: Understanding Ethereum Gas Fees

    Gas Optimization Part 1: Understanding Ethereum Gas Fees

    “I paid $62 just to send $100. What?”

    That’s the kind of reaction many new users have after making their first Ethereum transaction during peak congestion.

    No NFTs. No DeFi. Just a simple ETH transfer.

    Yet the gas fee was more than half the value of the transaction.

    And they thought it was a bug.

    But it wasn’t.

    It was Ethereum being busy.

    Welcome to the world of gas fees.

    What Is Gas, Really?

    If you’ve ever driven a car, you already understand gas.

    Think of your Ethereum transaction as a car trip. To drive (process your transaction), you need fuel, and on Ethereum, that fuel is called Gas.

    Just like fuel powers a car, gas powers your transaction on the Ethereum network.

    But there’s a catch: The busier the road, the higher the fuel price.

    So when the Ethereum network is crowded (say, during a hyped NFT mint), gas prices shoot up because everyone’s trying to get their transactions through.

    Why Gas Prices Change

    Back to our highway example:

    If traffic is light, fuel is cheap, and if traffic is jammed, fuel costs more to cut through

    Ethereum works similarly.

    You can pay a higher gas price to get your transaction picked up faster by validators

    Or you can set a lower price and wait.

    Understanding the Components

    Gas Limit

    This is the maximum amount of gas you’re willing to use.

    For simple ETH transfers, it’s usually 21,000.

    Gas Price

    This is how much you’re willing to pay per unit of gas, measured in Gwei.

    Gas Usage:

    This is the actual amount of gas consumed by your transaction. It’s often the same as your gas limit for simple transactions, but complex operations might use less than the limit you set.

    Breaking Down Gas Fees: A Real Example:

    • Gas Limit = 21,000
    • Gas Price = 35.06 Gwei
    • ETH Price = $3,492.21

    Step 1: Calculate Gas Fee in ETH

    21,000 × 35.06 / 1,000,000,000 = 0.000736 ETH

    Step 2: Convert to Dollars

    0.000736 × 3,492.21 = $2.57

    So, the fee for that simple transaction is about $2.57.

    But when the network gets congested, gas prices might 10x,  and that’s how people end up paying $50+ just to send ETH.

    The Game-Changer: EIP-1559

    In August 2021, Ethereum introduced EIP-1559, which revolutionized how gas fees work. Instead of the old auction-style system where users had to guess appropriate gas prices, EIP-1559 brought predictability and efficiency.

    How EIP-1559 Works

    The new system introduces several key components:

    Base Fee: This is a fixed price per unit of gas that the network automatically adjusts based on demand. Here’s the interesting part: this base fee gets burned (destroyed), permanently removing ETH from circulation.

    Max Fee: The maximum amount you’re willing to pay for the transaction. This acts as your safety net.

    Max Priority Fee: The tip you’re willing to give to miners to prioritize your transaction.

    A Real EIP-1559 Example

    Let’s say you’re making a transaction with these parameters:

    Base Fee: 70 Gwei

    Max Fee per Gas: 90 Gwei

    Max Priority Fee per Gas: 15 Gwei

    Here’s what happens:

    1. 70 Gwei gets burned (the base fee is destroyed)
    2. Miners receive 15 Gwei (your full priority fee since Max Fee – Base Fee = 20 Gwei, which is higher than your 15 Gwei priority fee)
    3. You get 5 Gwei refunded (90 – 70 – 15 = 5 Gwei back to your wallet)

    This system eliminates the guesswork. You know exactly what you’ll pay upfront, and any excess gets refunded automatically.

    Looking Ahead

    Gas optimization isn’t just about understanding current fees. It’s about developing strategies to minimize costs while maintaining transaction reliability. In the next part of this series, we’ll dive into practical techniques for optimizing your gas usage, including timing strategies, transaction batching, and smart contract optimization tips.

    The key takeaway? Gas fees might seem complex, but they follow predictable patterns. Once you understand these patterns, you can navigate the Ethereum network like a pro, saving money and avoiding the frustration of failed transactions.

    Remember: every Gwei saved is money back in your pocket. And in the world of DeFi and NFTs, where you might make dozens of transactions per month, those savings add up quickly.

  • How to spot Phishing Zoom Call Scams: Real Stories and Safety Tips

    How to spot Phishing Zoom Call Scams: Real Stories and Safety Tips

    Millions use Zoom every day, but imagine sitting down to join an important video call, only to realise minutes later that your computer is acting strangely and you have been hacked. This is the reality many people face with a phishing Zoom link. So let’s explore in this article what the phishing Zoom call scam is and how to stay safe.

    Before we continue, I would like to add that in most of these video meeting scams, the problem is not due to a bug/vulnerability in the official Zoom app or website, but scammers are targeting Zoom through a fake, phishing look a like link. 

    What are phishing Zoom Call Scams?

    Simply put, phishing Zoom call scams are fake video call invitations or messages that pretend to be from Zoom or someone you trust, but are designed to trick you. 

    Scammers might send an email saying you have missed a meeting or that your Zoom account has been hacked, prompting you to click a link that looks real but isn’t. Once you click, you might be taken to a fake login page that steals your username and password or downloads harmful software onto your device.

    Most common is that they would ask you to join a Zoom call from a phishing link (look-alike website with a few character differences). If you join the call, you will see their video, which is also not a real live video but a deep fake video, and you will not hear their voice. They will ask in chat, “We cannot hear you, maybe it is an issue from your Zoom, try updating it and rejoin the call.” Once you download and install it from their link, they will get remote access to your system, which will give them access to your data, passwords, etc. In case you or anyone in your network installs such software, one solution would be to disconnect your laptop from the internet to cut access and format/hard reset your operating system.

    You can see in the image below, Domain us02www-zoom.us, created in May 2025 and registered through NameCheap. Domains like this are often designed to look almost identical to Zoom’s official web address, tricking users into believing they are clicking a safe meeting link. Scammers use such lookalike domains to send fake Zoom invitations, aiming to steal login details or launch malware attacks. The fact is that this domain was registered recently, which is a red flag, and you can check this using Whois.

    How to spot Phishing Zoom Call Scams: Real Stories and Safety Tips

    Using tools like ScamBuzzer, you can also save yourself. This tool detects phishing sites and blocks such fake Zoom call links

    How to spot Phishing Zoom Call Scams: Real Stories and Safety Tips

    Real stories of people:

    • Daavya Vaishnav shared how scammers contacted her claiming to be part of the Avalanche team and expressed interest in organising a side event at Token2049. They reached out to her through Telegram groups and fake Zoom meeting invites, pretending to be trusted community members to gain her trust. The scammers aimed to trick her and others into clicking harmful links or sharing sensitive information.

    Check out the thread she shared:

    • Sagar Jethi recently shared how he was targeted by scammers on Telegram when an old contact, Zhixi Zhang (known as @build_on_bob), sent him a Zoom meeting link that turned out to be fake and part of a scam. Sagar suspects the Telegram account of this well-known marketing head might have been hacked or compromised by scammers

    Check out his tweet:

    • @chainyoda had their main Twitter handle hacked through a social engineering scam linked to a fake “Bloomberg interview”.

    He shared this on X:

    • Kaavya almost became a victim of a phishing Zoom scam involving deepfake technology. Someone she knows personally sent her a seemingly friendly message and a Calendly link to set up a catch-up call. But when the call started, instead of Google Meet, she was sent a Zoom link to a “team meeting,” which felt strange. On the Zoom call, she saw a deepfake video of Polygon’s founder, Sandeep Nailwal, and another person, moving and looking very real. Realizing this was a trick, she left immediately and asked to switch on Google Meet call. The scammer then disappeared, blocking her and erasing their profile.

    Check out this thread:

    Types of Zoom Call Scams

    There are a few common tricks scammers use:

    Fake Meeting Invitations: Emails or messages that tell you a meeting is scheduled or missed, containing malicious links.

    Phishing Login Pages: Fake Zoom sign-in pages that steal your username and password.

    Malicious Software Updates: Scam links pretending to be Zoom updates that install malware.

    Account Compromise Alerts: Emails claiming your Zoom account is hacked, prompting you to reset passwords on fake sites

    How to spot fake Zoom Scam Calls:

    • The email doesn’t come from an official Zoom email address but from a weird or suspicious one.
    • The email displays a link that, when hovered over, shows a strange or unrelated web address.
    • The message pushes you to act immediately, playing on your fear or urgency.
    • The email claims you missed a meeting you didn’t know about, or asks you to download updates directly from links.
    • In the call you can see but cannot hear their voice so they ask you, “Maybe you need to update Zoom”
    • Strange Meeting Links,  If the link doesn’t match the official company domain, don’t click.
    • If they are offering an investment return that seems impossible or a prize you didn’t enter for, it’s likely a scam.

    Zoom Call Security Best Practices

    • Only click meeting links from trusted sources.
    • Whenever possible, open your Zoom app directly and enter the meeting ID instead of clicking a link.
    • Keep your Zoom software updated by opening the app yourself, not through email links.
    • Check the sender’s email address carefully.
    • When in doubt, contact the person who supposedly sent the invite via another method to confirm.
    • Use two-factor authentication for your Zoom account.
    • Only enter login credentials in the official Zoom site, which is zoom.us and their official app.
    • Do not download or update Zoom software if they told you to do it now, and share the link in the call.
    • If something feels wrong, it probably is. Your instincts are usually right. It’s better to be slightly rude and protect yourself than to be polite and get scammed.

    Zoom has become an essential tool for connecting people worldwide, but like any popular tool, it attracts scammers looking to exploit trust and convenience. By knowing what phishing Zoom call scams look like and following simple safety steps, you can protect yourself from falling victim. Next time you get that unexpected Zoom invite, pause, look closely, and keep your online meetings secure.

    Do check out BlockchainHQ for more articles


  • They Lost Millions by Clicking ‘Sign’ – Here’s How to Never Make That Mistake

    They Lost Millions by Clicking ‘Sign’ – Here’s How to Never Make That Mistake

    Picture this: You’re the treasurer of a major crypto exchange. Your phone buzzes with a notification – another routine transaction needs approval. You glance at your screen, see familiar addresses, and click “approve” without a second thought. Within minutes, millions of dollars vanish into thin air.

    This isn’t fiction. This exact scenario played out when Bybit, one of the world’s largest cryptocurrency exchanges, fell victim to a sophisticated hack executed by North Korean cybercriminals. The culprit? A signer who didn’t fully verify a transaction, leading to a critical Safe UI vulnerability that drained millions from their multi-signature wallet.

    The harsh reality is that even the most secure wallet setups can crumble with one careless click. But here’s the good news: these disasters are completely preventable when you know what to look for.

    Don’t want to be the next victim?

    Let’s walk through how to verify calldata, use multi-sig safely, and pick the right wallet for your level.

    The Wallet Hierarchy: Choosing Your Guardian

    Before diving into verification techniques, let’s address the elephant in the room: which wallet should you even use?

    Total Beginner with Small Amounts: Start with custodial wallets or keep funds on reputable exchanges. Yes, “not your keys, not your crypto” is true, but losing $100 to exchange risk beats losing $100 to your own mistakes.

    Beginner with Small Money: Browser wallets like MetaMask or Phantom work well. They’re user-friendly and perfect for learning the ropes with amounts you can afford to lose.

    Intermediate Users with Medium Amounts: Hardware wallets like Ledger or Trezor become essential. They keep your private keys offline and away from internet threats.

    Intermediate Users with Large Amounts: Combine multi-signature wallets with hardware wallets. This creates multiple checkpoints that hackers must breach simultaneously.

    Advanced Users with Significant Holdings: Multi-signature wallets with social recovery, or custom solutions. At this level, you’re building Fort Knox for your digital assets.

    For wallet comparisons and security audits, check out walletscrutiny.com – it’s like a Consumer Reports for crypto wallets.

    Hot vs Cold Wallets

    Hot wallets stay connected to the internet (MetaMask, Phantom, and mobile apps). They’re convenient for daily transactions but vulnerable to online attacks.

    Cold wallets remain offline (Ledger, Trezor hardware devices). They’re like keeping cash in a physical safe, much harder to steal remotely.

    Important:

    Even a cold wallet becomes hot if you connect it to a Safe multi-sig UI!

    Always be aware of when you’re online vs offline

    Verifying Simple Transactions: Your First Line of Defense

    When using MetaMask or similar wallets, you’ll sometimes see transaction details that look like gibberish. Don’t panic,  here’s how to decode them:

    Check These Three Things:

    1. Estimated changes – What’s actually moving in and out of your wallet
    2. The “to” address – Where your money is going
    3. Hash data – The first 4 bytes reveal the function being called

    For example, if you see “0xa9059cbb” in your transaction data, you can decode it using Cast (a developer tool):

    cast sig “transfer(address,uint256)”

    This returns the function selector you can compare against your transaction. If they match, you’re calling a transfer function. If they don’t match, stop immediately.

    To verify the specific parameters of a transfer:

    cast calldata-decode “transfer(address,uint256)”

    This shows exactly where your tokens are going and how many.

    Multi-Sig Transactions: Where Things Get Complicated

    Multi-signature wallets require multiple people to approve transactions before they execute. Think of it like a shared bank account where both you and your spouse need to sign checks for large purchases

    Critical Point: A signature request is NOT the same as a transaction request. You’re not sending money yet, you’re just adding your approval to a pending transaction.

    How to Verify a Multi-Sig Transaction

    Step 1: Install the Right Tools Get Cyfrin’s Safe_hashes tool from GitHub

    https://github.com/Cyfrin/safe-tx-hashes?tab=readme-ov-file#curl

    This tool decodes Safe transactions into a human readable format.

    Step 2: Run the Verification Command

    safe_hashes –address –network –nonce

    If no transaction appears, use –untrusted mode in above command

    Step 3: Manual Verification (Advanced) For complete independence from APIs, use Cast:

    cast calldata “approve(address,uint256)”

    Then verify with Safe hashes:

    safe_hashes –address –network –nonce 2 –data –offline –to

    The Golden Rules That Could Save Millions

    Never sign and execute simultaneously. Some wallets try to streamline this process, but convenience is the enemy of security.

    Watch for operation codes. If you see “operation = 1” in your transaction, you’re looking at a DELEGATECALL – essentially giving another contract permission to act with your wallet’s full authority. This is extremely dangerous and should only be used in very specific circumstances.

    Always verify these three elements before any signature:

    • The destination address (where is this going?)
    • The function selector (what action is being performed?)
    • The value or amount (how much is involved?)

    Why This Matters More Than Ever

    The Bybit hack wasn’t an isolated incident. Similar attacks happen regularly because people skip verification steps. The difference between a secure transaction and a devastating hack often comes down to spending 30 seconds to verify what you’re actually signing.

    Remember: in the world of cryptocurrency, there’s no “undo” button. Once a transaction is confirmed on the blockchain, it’s permanent. The few minutes you spend verifying could be the difference between protecting your assets and reading about your loss in tomorrow’s crypto news.

    The tools and techniques outlined here aren’t just for crypto professionals – they’re for anyone who values their digital assets enough to protect them properly. Start with the basics, build good habits, and gradually level up your security practices as your holdings grow.

    TL;DR

    1. Pick the right wallet for your level
    2. Always verify the transaction before signing, especially calldata
    3. Never trust the UI blindly
    4. Use Safe_hashes or Cast for decoding
    5. Multi-sig ≠ automatic safety

    One wrong click can empty your wallet. Take 30 seconds and verify,  your future self will thank you.