@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:

npm install @moonup/wagmi-connector

Usage Examples

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

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

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

Last updated