Skip to content

Recipe: Wrap and unwrap ETH (WETH) programmatically #18

@PetarStoev02

Description

@PetarStoev02

Description

Recipe showing how to wrap ETH into WETH and unwrap it back — the gateway operation for almost every DeFi interaction.

Why this matters

Native ETH doesn't conform to the ERC-20 standard, but DeFi protocols need ERC-20 tokens. WETH (Wrapped ETH) solves this. Before you can deposit into Aave, swap on Uniswap, or provide liquidity — you often need WETH. It's the first step in any DeFi workflow.

Scope

  • Deposit ETH → get WETH (wrap)
  • Withdraw WETH → get ETH back (unwrap)
  • Check WETH balance
  • WETH contract addresses per chain
  • When you need WETH vs when protocols auto-wrap for you
  • Gas cost comparison: wrap vs direct ETH operations

w3-kit approach

  • Simple, clean viem pattern
  • Explain WHY WETH exists (ERC-20 compatibility)
  • Multi-chain WETH addresses from w3-kit registry
  • Integration with other DeFi recipes

Acceptance criteria

  • Recipe in recipes/evm/
  • Wrap and unwrap examples
  • Multi-chain WETH addresses
  • .learn.md explaining the WETH contract (deposit/withdraw pattern, why ETH isn't ERC-20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions