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

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

> **NOTE: Integrate Chainlink Local into your project**
>
> ### npm
>
> If you use [NPM](https://www.npmjs.com/), install the [@chainlink/local NPM
> package](https://www.npmjs.com/package/@chainlink/local):
>
> ```shell
> npm install @chainlink/local@0.2.3
> ```
>
> ### yarn
>
> If you use [Yarn](https://yarnpkg.com/), install the [@chainlink/local NPM
> package](https://www.npmjs.com/package/@chainlink/local):
>
> ```shell
> yarn add @chainlink/local@0.2.3
> ```
>
> ### foundry
>
> If you use [Foundry](https://book.getfoundry.sh/):
>
> ```shell
> forge install smartcontractkit/chainlink-local@7d8b2f888e1f10c8841ccd9e0f4af0f5baf11dab
> ```
>
> and then set remappings to: `@chainlink/local/=lib/chainlink-local/` in either `remappings.txt` or `foundry.toml` file
>
> ### RemixIDE
>
> Import the `CCIPLocalSimulator` contract from the `@chainlink/local` package:
>
> ```solidity
> import {CCIPLocalSimulator} from "@chainlink/local@0.2.3/src/ccip/CCIPLocalSimulator.sol";
> ```

## WETH9

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

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

> **NOTE**
>
> This contract provides functionality to wrap ETH into WETH and unwrap WETH back to ETH, along with standard ERC20
> operations.

## Variables

### allowance

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

> **NOTE**
>
> Mapping of owner addresses to spender addresses to approved amounts.

### balanceOf

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

> **NOTE**
>
> Mapping of addresses to their WETH balances.

### decimals

```solidity
uint8 public decimals = 18
```

> **NOTE**
>
> The number of decimals used for WETH token amounts.

### name

```solidity
string public name = "Wrapped Ether"
```

> **NOTE**
>
> The name of the token.

### symbol

```solidity
string public symbol = "WETH"
```

> **NOTE**
>
> The symbol of the token.

## Events

### Approval

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

> **NOTE**
>
> Emitted when an approval is set.

#### Parameters

| Parameter | Type      | Description                         |
| --------- | --------- | ----------------------------------- |
| src       | `address` | The address giving the approval     |
| guy       | `address` | The address receiving the approval  |
| wad       | `uint256` | The amount of tokens being approved |

### Deposit

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

> **NOTE**
>
> Emitted when ETH is wrapped to WETH.

#### Parameters

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

### Transfer

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

> **NOTE**
>
> Emitted when tokens are transferred.

#### Parameters

| Parameter | Type      | Description                            |
| --------- | --------- | -------------------------------------- |
| src       | `address` | The address sending the tokens         |
| dst       | `address` | The address receiving the tokens       |
| wad       | `uint256` | The amount of tokens being transferred |

### Withdrawal

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

> **NOTE**
>
> Emitted when WETH is unwrapped to ETH.

#### Parameters

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

## Functions

### approve

Approves another address to spend tokens.

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

> **NOTE**
>
> Sets the allowance that a spender has to access the caller's tokens.

#### 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

Deposits ETH to receive WETH.

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

> **NOTE**
>
> Allows users to deposit ETH and receive WETH tokens.

### totalSupply

Gets the total supply of WETH.

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

> **NOTE**
>
> Returns the total amount of ETH held by this contract.

#### Returns

| Parameter | Type      | Description              |
| --------- | --------- | ------------------------ |
| (unnamed) | `uint256` | The total supply of WETH |

### transfer

Transfers tokens to another address.

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

> **NOTE**
>
> Transfers tokens from the caller to another address.

#### Parameters

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

#### Returns

| Parameter | Type   | Description                           |
| --------- | ------ | ------------------------------------- |
| (unnamed) | `bool` | Returns true if the transfer succeeds |

### transferFrom

Transfers tokens from one address to another.

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

> **NOTE**
>
> Transfers tokens between addresses, respecting allowances.

#### 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` | Returns 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.

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

> **NOTE**
>
> Allows users to withdraw ETH by burning WETH tokens.

#### Parameters

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

#### Possible Reverts

- Reverts if the caller has insufficient WETH balance