API Version: v0.2.3

WETH9 v0.2.3 API Reference

WETH9

A contract that implements Wrapped Ether (WETH), allowing users to wrap and unwrap ETH.

WETH9

Variables

allowance

mapping(address => mapping(address => uint256)) public allowance

balanceOf

mapping(address => uint256) public balanceOf

decimals

uint8 public decimals = 18

name

string public name = "Wrapped Ether"

symbol

string public symbol = "WETH"

Events

Approval

event Approval(address indexed src, address indexed guy, uint256 wad)

Parameters

ParameterTypeDescription
srcaddressThe address giving the approval
guyaddressThe address receiving the approval
waduint256The amount of tokens being approved

Deposit

event Deposit(address indexed dst, uint256 wad)

Parameters

ParameterTypeDescription
dstaddressThe address receiving the WETH
waduint256The amount of ETH being wrapped

Transfer

event Transfer(address indexed src, address indexed dst, uint256 wad)

Parameters

ParameterTypeDescription
srcaddressThe address sending the tokens
dstaddressThe address receiving the tokens
waduint256The amount of tokens being transferred

Withdrawal

event Withdrawal(address indexed src, uint256 wad)

Parameters

ParameterTypeDescription
srcaddressThe address unwrapping the WETH
waduint256The amount of WETH being unwrapped

Functions

approve

Approves another address to spend tokens.

function approve(address guy, uint256 wad) public returns (bool)

Parameters

ParameterTypeDescription
guyaddressThe address to approve
waduint256The amount of tokens to approve

Returns

ParameterTypeDescription
(unnamed)boolAlways returns true

deposit

Deposits ETH to receive WETH.

function deposit() external payable

totalSupply

Gets the total supply of WETH.

function totalSupply() public view returns (uint256)

Returns

ParameterTypeDescription
(unnamed)uint256The total supply of WETH

transfer

Transfers tokens to another address.

function transfer(address dst, uint256 wad) public returns (bool)

Parameters

ParameterTypeDescription
dstaddressThe recipient address
waduint256The amount of tokens to transfer

Returns

ParameterTypeDescription
(unnamed)boolReturns true if the transfer succeeds

transferFrom

Transfers tokens from one address to another.

function transferFrom(address src, address dst, uint256 wad) public returns (bool)

Parameters

ParameterTypeDescription
srcaddressThe source address
dstaddressThe destination address
waduint256The amount of tokens to transfer

Returns

ParameterTypeDescription
(unnamed)boolReturns true if the transfer succeeds

Possible Reverts

  • Reverts if the source address has insufficient balance
  • Reverts if the caller has insufficient allowance (unless caller is source or has maximum allowance)

withdraw

Withdraws ETH by unwrapping WETH.

function withdraw(uint256 wad) external

Parameters

ParameterTypeDescription
waduint256The amount of WETH to unwrap

Possible Reverts

  • Reverts if the caller has insufficient WETH balance

Get the latest Chainlink content straight to your inbox.