# WETH9 v0.2.2 API Reference
Source: https://docs.chain.link/chainlink-local/api-reference/v0.2.2/weth9

> For the complete documentation index, see [llms.txt](/llms.txt).

<Common callout="importPackage022" />

## WETH9

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

[`WETH9`](https://github.com/smartcontractkit/chainlink-local/blob/cd3bfb8c42716cfb791174314eba2c0d178551b9/src/shared/WETH9.sol)

## Variables

### allowance

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

> \*\*NOTE\*\*
>
>
>
> Tracks the amount of tokens that an owner has allowed a spender to use.

### balanceOf

```solidity
mapping(address => uint256) public balanceOf
```

> \*\*NOTE\*\*
>
>
>
> Tracks the WETH balance of each address.

### decimals

```solidity
uint8 public decimals
```

> \*\*NOTE\*\*
>
>
>
> The number of decimal places used by the token (18).

### name

```solidity
string public name
```

> \*\*NOTE\*\*
>
>
>
> The name of the token ("Wrapped Ether").

### symbol

```solidity
string public symbol
```

> \*\*NOTE\*\*
>
>
>
> The symbol of the token ("WETH").

## Events

### Approval

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

Emitted when an approval is set.

#### Parameters

| Parameter | Type    | Description                   |
| --------- | ------- | ----------------------------- |
| src       | address | The owner of the tokens       |
| guy       | address | The approved spender          |
| wad       | uint256 | The amount of tokens approved |

### Deposit

```solidity
event Deposit(address indexed dst, uint256 wad)
```

Emitted when ETH is wrapped to WETH.

#### Parameters

| Parameter | Type    | Description               |
| --------- | ------- | ------------------------- |
| dst       | address | The recipient of the WETH |
| wad       | uint256 | The amount of ETH wrapped |

### Transfer

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

Emitted when tokens are transferred.

#### Parameters

| Parameter | Type    | Description                      |
| --------- | ------- | -------------------------------- |
| src       | address | The sender of the tokens         |
| dst       | address | The recipient of the tokens      |
| wad       | uint256 | The amount of tokens transferred |

### Withdrawal

```solidity
event Withdrawal(address indexed src, uint256 wad)
```

Emitted when WETH is unwrapped back to ETH.

#### Parameters

| Parameter | Type    | Description                  |
| --------- | ------- | ---------------------------- |
| src       | address | The address unwrapping WETH  |
| wad       | uint256 | The amount of WETH unwrapped |

## Functions

### approve

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

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

#### Parameters

| Parameter | Type    | Description                     |
| --------- | ------- | ------------------------------- |
| guy       | address | The address to approve          |
| wad       | uint256 | The amount of tokens to approve |

#### Returns

| Parameter | Type | Description         |
| --------- | ---- | ------------------- |
| (unnamed) | bool | Always returns true |

### deposit

Wraps ETH to WETH by sending ETH to the contract.

```solidity
function deposit() external payable
```

### totalSupply

Returns the total amount of WETH in circulation.

```solidity
function totalSupply() public view returns (uint256)
```

#### Returns

| Parameter | Type    | Description                                       |
| --------- | ------- | ------------------------------------------------- |
| (unnamed) | uint256 | The total supply of WETH (contract's ETH balance) |

### transfer

Transfers tokens to a specified address.

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

#### Parameters

| Parameter | Type    | Description                      |
| --------- | ------- | -------------------------------- |
| dst       | address | The recipient address            |
| wad       | uint256 | The amount of tokens to transfer |

#### Returns

| Parameter | Type | Description         |
| --------- | ---- | ------------------- |
| (unnamed) | bool | Always returns true |

### transferFrom

Transfers tokens from one address to another.

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

#### Parameters

| Parameter | Type    | Description                      |
| --------- | ------- | -------------------------------- |
| src       | address | The source address               |
| dst       | address | The destination address          |
| wad       | uint256 | The amount of tokens to transfer |

#### Returns

| Parameter | Type | Description         |
| --------- | ---- | ------------------- |
| (unnamed) | bool | Always returns true |

> **CAUTION**
>
> **Possible Reverts**

- Reverts if the source address has insufficient balance
- Reverts if the sender has insufficient allowance (unless allowance is maximum uint128 or sender is the source)

### withdraw

Unwraps WETH back to ETH.

```solidity
function withdraw(uint256 wad) external
```

#### Parameters

| Parameter | Type    | Description                  |
| --------- | ------- | ---------------------------- |
| wad       | uint256 | The amount of WETH to unwrap |

> **CAUTION**
>
> **Possible Reverts**

- Reverts if the sender has insufficient WETH balance