WETH9 v0.2.2 API Reference
A contract that implements Wrapped Ether (WETH), allowing users to wrap and unwrap ETH to use it as an ERC20-compatible token.
WETH9
mapping(address => mapping(address => uint256)) public allowance
mapping(address => uint256) public balanceOf
uint8 public decimals
string public name
string public symbol
event Approval(address indexed src, address indexed guy, uint256 wad)
Emitted when an approval is set.
Parameter | Type | Description |
---|
src | address | The owner of the tokens |
guy | address | The approved spender |
wad | uint256 | The amount of tokens approved |
event Deposit(address indexed dst, uint256 wad)
Emitted when ETH is wrapped to WETH.
Parameter | Type | Description |
---|
dst | address | The recipient of the WETH |
wad | uint256 | The amount of ETH wrapped |
event Transfer(address indexed src, address indexed dst, uint256 wad)
Emitted when tokens are transferred.
Parameter | Type | Description |
---|
src | address | The sender of the tokens |
dst | address | The recipient of the tokens |
wad | uint256 | The amount of tokens transferred |
event Withdrawal(address indexed src, uint256 wad)
Emitted when WETH is unwrapped back to ETH.
Parameter | Type | Description |
---|
src | address | The address unwrapping WETH |
wad | uint256 | The amount of WETH unwrapped |
Approves a spender to transfer tokens on behalf of the owner.
function approve(address guy, uint256 wad) public returns (bool)
Parameter | Type | Description |
---|
guy | address | The address to approve |
wad | uint256 | The amount of tokens to approve |
Parameter | Type | Description |
---|
(unnamed) | bool | Always returns true |
Wraps ETH to WETH by sending ETH to the contract.
function deposit() external payable
Returns the total amount of WETH in circulation.
function totalSupply() public view returns (uint256)
Parameter | Type | Description |
---|
(unnamed) | uint256 | The total supply of WETH (contract's ETH balance) |
Transfers tokens to a specified address.
function transfer(address dst, uint256 wad) public returns (bool)
Parameter | Type | Description |
---|
dst | address | The recipient address |
wad | uint256 | The amount of tokens to transfer |
Parameter | Type | Description |
---|
(unnamed) | bool | Always returns true |
Transfers tokens from one address to another.
function transferFrom(address src, address dst, uint256 wad) public returns (bool)
Parameter | Type | Description |
---|
src | address | The source address |
dst | address | The destination address |
wad | uint256 | The amount of tokens to transfer |
Parameter | Type | Description |
---|
(unnamed) | bool | Always returns true |
Unwraps WETH back to ETH.
function withdraw(uint256 wad) external
Parameter | Type | Description |
---|
wad | uint256 | The amount of WETH to unwrap |