# EVM compatible

This guide will walk you through the process of integrating Kastle with your EVM-compatible decentralized application (dApp) using RainbowKit and wagmi.

{% hint style="danger" %}
Kastle currently only supports Kaia testnet (Kairos) and basic Ethereum methods.
{% endhint %}

### Installation

First, ensure you have the required dependencies:

```bash
npm install @rainbow-me/rainbowkit wagmi viem
# or
yarn add @rainbow-me/rainbowkit wagmi viem
```

### Integration

Add the following code to your RainbowKit configuration:

```typescript
import { getDefaultConfig, Wallet } from "@rainbow-me/rainbowkit";
import { kairos } from "wagmi/chains";
import { injected, createConnector } from "wagmi";

const kastleWallet = (): Wallet => ({
  id: "kastle",
  name: "Kastle",
  iconUrl:
    "https://media.rhyzome.co/media/kastle-symbol-logo.svg",
  downloadUrls: {
    chrome:
      "https://chromewebstore.google.com/detail/kastle/oambclflhjfppdmkghokjmpppmaebego?authuser=0&hl=en",
  },
  iconBackground: "#FFFFFF",
  createConnector: createKastleConnector(),
});

function getWindowProviderNamespace(namespace: string) {
  const providerSearch = (provider: any, namespace: string): any => {
    const [property, ...path] = namespace.split(".");
    const _provider = provider[property];
    if (_provider) {
      if (path.length === 0) return _provider;
      return providerSearch(_provider, path.join("."));
    }
  };
  if (typeof window === "undefined") return;
  const provider = providerSearch(window, namespace);
  if (provider) return provider;
}

function createKastleConnector() {
  return (walletDetails: any) => {
    const injectedConfig = {
      target: () => {
        const provider = getWindowProviderNamespace("kastle.ethereum");
        if (!provider) {
          return;
        }

        return {
          id: walletDetails.rkDetails.id,
          name: walletDetails.rkDetails.name,
          provider: provider,
        };
      },
    };

    return createConnector((config) => ({
      ...injected(injectedConfig)(config),
      ...walletDetails,
    }));
  };
}

export const config = getDefaultConfig({
  appName: "RainbowKit demo",
  projectId: "YOUR_PROJECT_ID",
  chains: [kairos],
  wallets: [
    {
      groupName: "Popular wallets",
      wallets: [kastleWallet],
    },
  ],
  ssr: true,
});
```


---

# 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.kastle.cc/readme/evm-compatible.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.
