# @moonup/wagmi-connector

## @moonup/wagmi-connector Package Documentation

The `@moonup/wagmi-connector` package is a connector for the `wagmi` library that allows for the integration of the MoonSDK from the `@moonup/moon-sdk` package. This connector can be used to connect to a Moon wallet and interact with Ethereum-based blockchains.

## **Installing Moon Wagmi:**

To use the Moon Wagmi package, first install it to a project:

#### To install Moon Wagmi:

{% tabs %}
{% tab title="npm" %}

```bash
npm install @moonup/wagmi-connector
```

{% endtab %}

{% tab title="yarn" %}

```bash
yarn add @moonup/wagmi-connector
```

{% endtab %}

{% tab title="pnpm" %}

```bash
pnpm add @moonup/wagmi-connector
```

{% endtab %}
{% endtabs %}

### Usage Examples

Here's a basic example of how to use the `createMoonConnector` function:

```javascript
import { MoonSDK } from '@moonup/moon-sdk';
import { createMoonConnector } from '@moonup/wagmi-connector';
import { WagmiConfig, createClient, configureChains } from 'wagmi';
import { publicProvider } from 'wagmi/providers/public';

const { chains, provider } = configureChains([chain], [publicProvider()]);

const SDK = new MoonSDK({ /* your configuration */ });
const address = '0xYourEthereumAddress';
const chainId = 1; // mainnet

const client = createClient({
  autoConnect: true,
  provider,
  connectors: [
    createMoonConnector({ SDK, address, chainId, chains }),
  ],
});

function App() {
  return (
    <WagmiConfig client={client}>
      {/* Your app components */}
    </WagmiConfig>
  );
}
```

### API Reference

#### `createMoonConnector`

Creates a connector for the `wagmi` library using the MoonSDK.

**Parameters**

* `options` (Object)
  * `SDK` (MoonSDK): An instance of the MoonSDK.
  * `address` (string): The Ethereum address of the account.
  * `chainId` (number): The ID of the Ethereum chain.
  * `chains` (Chain\[]): An array of Ethereum chains.

**Returns**

A `CreateConnectorFn` function that can be used to create a connector for the `wagmi` library.

**Example**

```javascript
const connector = createMoonConnector({ SDK, address, chainId, chains });
```


---

# 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.usemoon.ai/additional-moon-packages-7ca327c0bb2846d88b8ba5bc6caeaead/moon-wagmi-3d44fd4699594c2397129482dc52589f.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.
