# Connect MetaMask

MetaMask doesn't ship with AEREDIUM as a built-in network, so you'll add it as a custom RPC. Same flow works for any EVM wallet (Rabby, OKX, Frame, Coinbase Wallet, etc.).

## Add the network manually

1. Open MetaMask → click the network dropdown (top-left) → **Add a custom network**.
2. Fill in:

   | Field              | Value                     |
   | ------------------ | ------------------------- |
   | Network name       | `AEREDIUM`                |
   | Default RPC URL    | `https://rpc.aeredium.io` |
   | Chain ID           | `1000`                    |
   | Currency symbol    | `AER`                     |
   | Block explorer URL | *(coming soon)*           |
3. Click **Save**, then switch to the AEREDIUM network from the dropdown.

That's it — your account address is the same as on any EVM chain, and you'll see your AER balance once you have funds.

## Add the network programmatically (dApps)

Inside a dApp, you can prompt the user to add and switch to AEREDIUM in one click using EIP-3085 / EIP-3326:

```ts
async function connectAeredium() {
  const ethereum = (window as any).ethereum;
  if (!ethereum) throw new Error("No EVM wallet detected");

  try {
    // Try to switch first — if the network is already added, this just works
    await ethereum.request({
      method: "wallet_switchEthereumChain",
      params: [{ chainId: "0x3e8" }], // 1000 in hex
    });
  } catch (err: any) {
    // 4902 = chain not added yet → add it
    if (err.code === 4902) {
      await ethereum.request({
        method: "wallet_addEthereumChain",
        params: [
          {
            chainId: "0x3e8",
            chainName: "AEREDIUM",
            nativeCurrency: { name: "AER", symbol: "AER", decimals: 18 },
            rpcUrls: ["https://rpc.aeredium.io"],
            blockExplorerUrls: [], // populate when explorer is live
          },
        ],
      });
    } else {
      throw err;
    }
  }
}
```

## Verify you're connected

After switching, test in the browser console:

```js
await ethereum.request({ method: "eth_chainId" }); // → "0x3e8"
await ethereum.request({ method: "eth_blockNumber" });
```

## Troubleshooting

**MetaMask says "Could not fetch chain ID. Is your RPC URL correct?"** Make sure you typed `https://rpc.aeredium.io` exactly. Some browsers strip `https://` — re-paste it.

**Transactions stuck "pending" in MetaMask** AEREDIUM has 2-second blocks. If a tx sits pending more than \~10 seconds, the nonce is likely wrong. Reset MetaMask's account activity: Settings → Advanced → **Clear activity tab data**.

**Wrong balance / stale data** MetaMask aggressively caches. Switch to a different network and back, or restart the extension.


---

# 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://aeredium.gitbook.io/developer.aeredium.io/network/metamask.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.
