# Vault

The Vault class wraps a given vault contract and provides all necessary view and write functions to interact with any given vault.

> Currently we are using the word **`Adapter`** and **`Strategy`** interchangeably. In V2 we will simplify this wording to name every yield-earning contract a **`Strategy`**.

### Initialization

The Vault class must be created for each vault contract you wish to interact with. To initialize it, you'll need the vault's address, a public client for reading, and a wallet client for making changes. We use viem's public and wallet clients.

* The public client fetches data from the chain using a JSON-RPC API
* The wallet client connects with an Externally Owned Account (EOA) to enable user transaction signing.

To find the addresses of all existing vaults on a chain, you can use the "allVaults" function of the VaultRegistry contract, such as through etherscan.

Find current VaultRegistry addresses here:

```tsx
mainnet: "0x007318Dc89B314b47609C684260CfbfbcD412864"
optimism: "0xdD0d135b5b52B7EDd90a83d4A4112C55a1A6D23A"
arbitrum: "0xB205e94D402742B919E851892f7d515592a7A6cC"
polygon: "0x2246c4c469735bCE95C120939b0C078EC37A08D0"
bsc: "0x25172C73958064f9ABc757ffc63EB859D7dc2219"
```

We are developing a VaultRegistry class for our SDK to simplify this process. Additionally, our app will soon include a dedicated page for you to conveniently view and manage all your vaults.

To initialize the Vault class simply follow this example:

```tsx
const vaultAddress = "0x5d344226578DC100b2001DA251A4b154df58194f",
const publicClient = createPublicClient({
  chain: mainnet,
  transport: http()
})
const walletClient = createWalletClient({
  chain: mainnet,
  transport: custom(window.ethereum)
})

const vault = new Vault(vaultAddress, publicClient, walletClient);
```

> Check our [GitHub](https://github.com/Popcorn-Limited/vaultcraft-sdk/blob/main/docs/vault.md) for available methods.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vaultcraft.io/products/vaultcraft-vci-and-sdk/sdk/vault.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
