Ethereum Development

EthereumFree Lesson

Advertisement

Ethereum Development

EVM, gas optimization, development tools, and dApp architecture.

Overview

Ethereum is a programmable blockchain for decentralized applications.

Development Stack

ToolPurpose
HardhatDevelopment environment
FoundryFast testing framework
ethers.jsJavaScript library
OpenZeppelinContract library
Alchemy/InfuraNode providers

Hardhat Configuration

// hardhat.config.js
module.exports = {
  solidity: {
    version: "0.8.19",
    settings: {
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  },
  networks: {
    sepolia: {
      url: process.env.ALCHEMY_URL,
      accounts: [process.env.PRIVATE_KEY]
    }
  }
};

EVM Basics

// Storage operations (expensive)
uint256 public count; // SSTORE: 20,000 gas

// Memory operations (cheap)
function example() public pure returns (uint256) {
    uint256 temp = 100; // MSTORE: 3 gas
    return temp;
}

Gas Optimization

// Bad: Multiple storage writes
function bad() public {
    count = count + 1;
    count = count + 1;
}

// Good: Single storage write
function good() public {
    count += 2;
}

// Use calldata instead of memory
function good(string calldata data) public {
    // Read-only, cheaper
}

dApp Architecture

Architecture Diagram
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│           Frontend (React)          │
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
│           Web3 Library              │
│  (ethers.js, web3.js)               │
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
│           Smart Contracts           │
│  (Solidity)                         │
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
│           Ethereum Network          │
│  (Nodes, Miners/Validators)         │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Practice

Build a full-stack dApp with Hardhat and React.

Advertisement

Need Expert Blockchain Help?

Get personalized Web3 training or smart contract consulting.

Advertisement