clawchain/claw-wallet-mobile/apps/docs_web/docs/v0/sdk-usage/interchain-kit-integration.md

4.4 KiB

title, sidebar_position
title sidebar_position
Interchain Kit Integration 7

Interchain Kit Integration

:::warning Beta Feature This integration is currently in beta. APIs may change in future releases. EVM chain connections are not yet supported. :::

Learn how to integrate Claw Wallet with Interchain Kit, the multi-chain wallet adapter for Cosmos ecosystem applications.

:::tip Get started faster Prefer a ready-to-run example? Try the Interchain Kit (Next.js) starter template. :::

Overview

@oko-wallet/oko-interchain-kit is an Interchain Kit wallet connector that enables your application to use Claw Wallet alongside other Cosmos wallets. This integration provides a seamless embedded wallet experience while maintaining compatibility with the Interchain Kit ecosystem.

Installation

Install the required packages:

npm install @oko-wallet/oko-interchain-kit @interchain-kit/react @interchain-kit/core

Basic Setup

1. Create Claw Wallet

Use makeOkoWallet to create a wallet instance:

import { makeOkoWallet } from "@oko-wallet/oko-interchain-kit";

const okoWallet = makeOkoWallet({
  apiKey: "your-oko-api-key",
  sdkEndpoint: "https://your-custom-oko-sdk.example.com", // optional, Only specify if you have your own SDK endpoint
});

2. Configure ChainProvider

Wrap your application with Interchain Kit's ChainProvider and include the Oko wallets:

import { ChainProvider } from "@interchain-kit/react";
import { makeOkoWallet } from "@oko-wallet/oko-interchain-kit";
import { chains, assetLists } from "@chain-registry/v2";

const okoWallet = makeOkoWallet({
  apiKey: "your-oko-api-key",
});

export default function App({ Component, pageProps }) {
  return (
    <ChainProvider
      chains={chains}
      assetLists={assetLists}
      wallets={[okoWallet]}
    >
      <Component {...pageProps} />
    </ChainProvider>
  );
}

3. Connect to Claw Wallet

Use the standard Interchain Kit hooks to interact with Claw Wallet:

import { useChain } from "@interchain-kit/react";
import { WalletState } from "@interchain-kit/core";

function WalletConnect() {
  const { openView, disconnect, address, status } = useChain("osmosis");

  return (
    <div>
      {status === WalletState.Connected ? (
        <div>
          <p>Connected: {address}</p>
          <button onClick={disconnect}>Disconnect</button>
        </div>
      ) : (
        <button onClick={openView}>Connect</button>
      )}
    </div>
  );
}

Configuration Options

OkoWalletOptions

The makeOkoWallet function accepts the following options:

interface OkoWalletOptions {
  // Your Oko API key (required)
  apiKey: string;

  // Custom SDK endpoint (optional)
  // Defaults to Oko's production endpoint
  sdkEndpoint?: string;
}

Login Providers

When connecting, users can select their preferred login provider from a modal:

  • Google OAuth
  • Email/passwordless
  • X (Twitter) OAuth
  • Telegram OAuth
  • Discord OAuth

Signing Transactions

Interchain Kit provides the wallet object for signing transactions:

import { useChain } from "@interchain-kit/react";
import { SigningStargateClient } from "@cosmjs/stargate";

function SendTransaction() {
  const { address, wallet, getRpcEndpoint } = useChain("osmosis");

  const sendTokens = async () => {
    const offlineSigner = await wallet?.getOfflineSigner();
    if (!offlineSigner || !address) return;

    const rpcEndpoint = await getRpcEndpoint();
    const client = await SigningStargateClient.connectWithSigner(
      rpcEndpoint,
      offlineSigner,
    );

    const result = await client.sendTokens(
      address,
      "osmo1recipientaddress",
      [{ denom: "uosmo", amount: "1000" }],
      "auto",
    );

    console.log("Transaction hash:", result.transactionHash);
  };

  return <button onClick={sendTokens}>Send Tokens</button>;
}

Next Steps

Resources