API Version: v0.2.2 Not using latest version (v0.2.3)

WETH9 v0.2.2 API Reference

WETH9

A contract that implements Wrapped Ether (WETH), allowing users to wrap and unwrap ETH to use it as an ERC20-compatible token.

WETH9

Variables

allowance

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

balanceOf

mapping(address => uint256) public balanceOf

decimals

uint8 public decimals

name

string public name

symbol

string public symbol

Events

Approval

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

Emitted when an approval is set.

Parameters

ParameterTypeDescription
srcaddressThe owner of the tokens
guyaddressThe approved spender
waduint256The amount of tokens approved

Deposit

event Deposit(address indexed dst, uint256 wad)

Emitted when ETH is wrapped to WETH.

Parameters

ParameterTypeDescription
dstaddressThe recipient of the WETH
waduint256The amount of ETH wrapped

Transfer

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

Emitted when tokens are transferred.

Parameters

ParameterTypeDescription
srcaddressThe sender of the tokens
dstaddressThe recipient of the tokens
waduint256The amount of tokens transferred

Withdrawal

event Withdrawal(address indexed src, uint256 wad)

Emitted when WETH is unwrapped back to ETH.

Parameters

ParameterTypeDescription
srcaddressThe address unwrapping WETH
waduint256The amount of WETH unwrapped

Functions

approve

Approves a spender to transfer tokens on behalf of the owner.

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

Wraps ETH to WETH by sending ETH to the contract.

function deposit() external payable

totalSupply

Returns the total amount of WETH in circulation.

function totalSupply() public view returns (uint256)

Returns

ParameterTypeDescription
(unnamed)uint256The total supply of WETH (contract's ETH balance)

transfer

Transfers tokens to a specified address.

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

Parameters

ParameterTypeDescription
dstaddressThe recipient address
waduint256The amount of tokens to transfer

Returns

ParameterTypeDescription
(unnamed)boolAlways returns true

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)boolAlways returns true

withdraw

Unwraps WETH back to ETH.

function withdraw(uint256 wad) external

Parameters

ParameterTypeDescription
waduint256The amount of WETH to unwrap

Get the latest Chainlink content straight to your inbox.