> For the complete documentation index, see [llms.txt](https://docs.aurowallet.com/general/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aurowallet.com/general/howto/add-or-switch-chain.md).

# Add or Switch Chain

Scenarios for interact chain with Auro Wallet.

## RequestNetwork

During initialization, zkApp can get current networkID by call `requestNetwork`.

```typescript
const network: ChainInfoArgs = await window.mina?.requestNetwork()
  .catch((err: any) => err);
```

## `SwitchChain`

zkApp can switch chain by this method.&#x20;

The following are the networkID that Auro supports by default. If you want to use other networkID, need to add network first, then use the target networkID as a parameter to switch.

> Current support these networkID (default):
>
> * mina:mainnet
> * mina:devnet // Update from mina:testnet to mina:devnet from extension 2.3.1, App 2.1.0
> * zeko:testnet

```typescript
type ChainInfoArgs = {
    networkID: string;
};

interface ProviderError extends Error {
    message: string;
    code: number;
    data?: unknown;
}

const switchResult:ChainInfoArgs|ProviderError = await window.mina
    ?.switchChain({
        networkID: networkID.trim(),
    }).catch((err: any) => err);
```

{% hint style="danger" %}

```markdown
** Please update as soon as possible. **
`ChainInfoArgs` params have updated from App 2.0.2 & extension 2.2.17.
Only `networkID` is returned, no longer supports returning `chainId` and `name`. 

// @deprecated from App 2.0.2 & extension 2.2.17.
type ChainInfoArgs ={ 
    chainId:string,
    name:string
}
```

{% endhint %}

## Add Chain

If want to custom the adding chain or switch chain, can use this method. When the URL has been added, it will request to switch to chain corresponding to the URL.

```typescript
const addInfo = {
  url: encodeURIComponent("graphQLURL"),
  name: "networkName",
}

const addResult:ChainInfoArgs|ProviderError = await window.mina?.addChain(addInfo)
  .catch((err: any) => err);
```

## Chain Event

This method is used to listen chain changes. When the Auro Wallet chain change, the event will be trigger.

```typescript
window.mina?.on("chainChanged",(chainInfo: ChainInfoArgs) => {
  console.log(chainInfo);
});
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.aurowallet.com/general/howto/add-or-switch-chain.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
