Educational · public chain example

Smart contracts & crypto risk How on-chain source looks — and what users should know

BaseDex is a market tracker and watch-only viewer. This page uses a well-known public contract on Base as an example of how Solidity source is published. It is not a BaseDex product contract, and it does not hold your keys.

No custody

Public example contracts still cannot replace a wallet. Never enter a recovery phrase or private key into BaseDex.

Layout flag only

Open-source Solidity is published so anyone can read it. Listing an example is not an invitation to trade or deposit funds.

Crypto is risky

Prices move quickly. You can lose money. Nothing on this page or in the app is investment, tax, or legal advice.

Example public contract

Wrapped Ether (WETH) on Base — a widely used, publicly verified contract. Shown here as a teaching example only. It is not operated by BaseDex.

Network

Base (chain ID 8453)

Example address (WETH)

0x4200000000000000000000000000000000000006

Open on Basescan

Agreement & risk

By using BaseDex or visiting this page, you acknowledge the following.

  • You use cryptocurrency markets at your own risk. Values can go to zero.
  • On-chain data can be delayed, incomplete, or wrong. Explorers and RPCs are third parties.
  • Example contracts on this page are third-party public code. They are not BaseDex custody or a place to send funds.
  • Public addresses you watch are visible on the blockchain. Do not share secrets.
  • BaseDex is independent and is not affiliated with Coinbase, Base, or any exchange.

Full terms: Terms of Use · Privacy Policy

Example Solidity source

Canonical Wrapped Ether (WETH9) — open, widely copied reference code so you can see how a real smart-contract source file looks. This is not BaseDex software. Prefer the verified copy on Basescan.

// Copyright (C) 2015, 2016, 2017 Dapphub
// SPDX-License-Identifier: GPL-3.0-or-later
// Canonical WETH9 — public reference implementation (example only).

pragma solidity ^0.4.18;

contract WETH9 {
    string public name     = "Wrapped Ether";
    string public symbol   = "WETH";
    uint8  public decimals = 18;

    event  Approval(address indexed src, address indexed guy, uint wad);
    event  Transfer(address indexed src, address indexed dst, uint wad);
    event  Deposit(address indexed dst, uint wad);
    event  Withdrawal(address indexed src, uint wad);

    mapping (address => uint)                       public  balanceOf;
    mapping (address => mapping (address => uint))  public  allowance;

    function() public payable {
        deposit();
    }
    function deposit() public payable {
        balanceOf[msg.sender] += msg.value;
        Deposit(msg.sender, msg.value);
    }
    function withdraw(uint wad) public {
        require(balanceOf[msg.sender] >= wad);
        balanceOf[msg.sender] -= wad;
        msg.sender.transfer(wad);
        Withdrawal(msg.sender, wad);
    }

    function totalSupply() public view returns (uint) {
        return this.balance;
    }

    function approve(address guy, uint wad) public returns (bool) {
        allowance[msg.sender][guy] = wad;
        Approval(msg.sender, guy, wad);
        return true;
    }

    function transfer(address dst, uint wad) public returns (bool) {
        return transferFrom(msg.sender, dst, wad);
    }

    function transferFrom(address src, address dst, uint wad)
        public
        returns (bool)
    {
        require(balanceOf[src] >= wad);

        if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
            require(allowance[src][msg.sender] >= wad);
            allowance[src][msg.sender] -= wad;
        }

        balanceOf[src] -= wad;
        balanceOf[dst] += wad;

        Transfer(src, dst, wad);

        return true;
    }
}