Introduction

The Kiroro SDK v2.0 provides everything you need to build social-native dApps. It combines Threads login, embedded wallets, and full transaction capabilities across multiple chains.

v2.0.0: Now with sendTransaction, writeContract, signMessage, multi-chain support, and Wagmi integration!
Supported Chains: Base, Base Sepolia, Arbitrum, Optimism, Polygon, Ethereum Mainnet

Installation

Install the Kiroro SDK and its peer dependencies via your preferred package manager.

npm install @kirorolabs/sdk viem @solana/web3.js @privy-io/react-auth

Configuration

Wrap your application with the KiroroProvider. You only need the client ID from your dashboard.

layout.tsx
import { KiroroProvider } from "@kirorolabs/sdk";

export default function RootLayout({ children }) {
  return (
    <KiroroProvider 
      config={{
        kiroroClientId: "kiro_abc123...", // Get this from Dashboard > Projects
        gasless: true
      }}
    >
      {children}
    </KiroroProvider>
  );
}

Authentication

The SDK provides a simple React hook to handle the entire authentication lifecycle.

The `useKiroroAuth` Hook

This hook exposes everything you need to log users in, check their status, and access their profile.

Profile.tsx
import { useKiroroAuth } from "@kirorolabs/sdk";

export function Profile() {
  const { 
    user,              // The user profile object
    login,             // Function to start login flow
    logout,            // Function to sign out
    isAuthenticated,   // Boolean status
    isLoading          // Loading state
  } = useKiroroAuth();

  if (isLoading) return <div>Loading...</div>;

  if (!isAuthenticated) {
    return (
      <button onClick={login} className="btn-primary">
        Connect with Threads
      </button>
    );
  }

  return (
    <div className="profile-card">
      <img src={user.picture} alt={user.username} />
      <h2>@{user.username}</h2>
      <p>Wallet: {user.walletAddress}</p>
      <button onClick={logout}>Sign Out</button>
    </div>
  );
}

User Object Structure

interface KiroroUser {
  id: string;                // Unique Kiroro ID
  threadsId: string;         // Original Threads User ID
  username: string;          // Threads username
  picture: string;           // Profile picture URL
  walletAddress?: string;    // Smart Wallet Address
  smartWalletAddress?: string; // ERC-4337 Smart Wallet
  eoaAddress?: string;       // Underlying EOA signer
  chainId?: number;          // Current chain
  isVerified?: boolean;      // Threads verification status
}

Wallet & Transactions

The useKiroroWallet hook provides full transaction capabilities for your dApp.

Sending Transactions

SendETH.tsx
import { useKiroroWallet } from "@kirorolabs/sdk";

export function SendButton() {
  const { sendTransaction, isReady, address } = useKiroroWallet();

  const handleSend = async () => {
    const hash = await sendTransaction({
      to: "0x1234...",
      value: BigInt(1e16), // 0.01 ETH
    });
    console.log("Transaction sent:", hash);
  };

  return (
    <button onClick={handleSend} disabled={!isReady}>
      Send 0.01 ETH
    </button>
  );
}

Calling Smart Contracts

MintNFT.tsx
import { useKiroroWallet } from "@kirorolabs/sdk";

export function MintButton() {
  const { writeContract, isReady } = useKiroroWallet();

  const handleMint = async () => {
    const hash = await writeContract({
      address: "0xContractAddress...",
      abi: NFT_ABI,
      functionName: "mint",
      args: ["0xRecipient...", 1],
    });
  };

  return <button onClick={handleMint}>Mint NFT</button>;
}

Signing Messages

SignMessage.tsx
const { signMessage } = useKiroroWallet();

const signature = await signMessage("Hello, Kiroro!");
console.log("Signature:", signature);

Available Methods

sendTransaction() - Send ETH or raw tx
writeContract() - Call contract functions
signMessage() - Sign plain text
signTypedData() - EIP-712 signing
switchChain() - Change networks
waitForTransaction() - Wait for confirmation

Solana Support ☀️

Kiroro SDK v2.0 introduces first-class support for Solana. Interact with the Solana blockchain using the same unified identity.

The `useKiroroSolana` Hook

Solana.tsx
import { useKiroroSolana } from "@kirorolabs/sdk";
import { Connection, LAMPORTS_PER_SOL, SystemProgram, Transaction } from "@solana/web3.js";

export function SolanaButton() {
  const { 
    connect,           // Connect Solana wallet
    signMessage,       // Sign text message
    sendTransaction,   // Send transaction
    walletAddress,     // Solana public key
    isConnected        // Connection status
  } = useKiroroSolana();

  const handleSendSol = async () => {
    if (!walletAddress) return;

    const connection = new Connection("https://api.devnet.solana.com");
    
    const transaction = new Transaction().add(
      SystemProgram.transfer({
        fromPubkey: new PublicKey(walletAddress),
        toPubkey: new PublicKey("RecipientAddress..."),
        lamports: LAMPORTS_PER_SOL * 0.1,
      })
    );

    const { blockhash } = await connection.getLatestBlockhash();
    transaction.recentBlockhash = blockhash;
    transaction.feePayer = new PublicKey(walletAddress);

    const txid = await sendTransaction(transaction, connection);
    console.log("Transaction ID:", txid);
  };

  return (
    <button onClick={handleSendSol} disabled={!isConnected}>
      Send 0.1 SOL
    </button>
  );
}

Helper Hooks

useKiroroToken

Convenience hook for ERC-20 token operations.

import { useKiroroToken } from "@kirorolabs/sdk";

const { balance, transfer, approve } = useKiroroToken("0xTokenAddress");

// Transfer tokens
await transfer("0xRecipient", BigInt(1e18));

// Approve spender
await approve("0xSpender", BigInt(1e18));

useKiroroNFT

Convenience hook for ERC-721 NFT operations.

import { useKiroroNFT } from "@kirorolabs/sdk";

const { balance, transfer, ownerOf } = useKiroroNFT("0xNFTContract");

// Transfer an NFT
await transfer("0xRecipient", BigInt(tokenId));

Wagmi Integration

Use standard Wagmi hooks with the Kiroro wallet.

wagmi.config.ts
import { kiroroWagmiConnector } from "@kirorolabs/sdk/wagmi";
import { createConfig } from "wagmi";

const config = createConfig({
  connectors: [kiroroWagmiConnector()],
  // ... rest of wagmi config
});

// Now useWriteContract() works with Kiroro!

Advanced Usage

Fetching Data

Use the getAccessToken() method to securely retrieve a Threads Access Token and fetch user data from the Graph API.

UserPosts.tsx
import { useKiroroAuth} from "@kirorolabs/sdk";
                            import {useState, useEffect} from "react";

                            export function UserPosts() {
  const {getAccessToken} = useKiroroAuth();
                            const [posts, setPosts] = useState([]);

  useEffect(() => {
                                async function loadPosts() {
                                    const token = await getAccessToken();
                                    if (!token) return;

                                    // Call Threads Graph API directly
                                    const res = await fetch(`https://graph.threads.net/v1.0/me/threads?access_token=${token}`);
                            const data = await res.json();

                            setPosts(data.data);
    }

                            loadPosts();
  }, [getAccessToken]);

                            return (
                            <div>
                                {posts.map(post => (
                                    <div key={post.id}>{post.text}</div>
                                ))}
                            </div>
                            );
}

Security & Identity

Security is built into the core of the Kiroro SDK. When using Managed Auth, your application's security is guaranteed by two main layers:

Domain Whitelisting

Even if your App ID is public, only requests from domains you whitelist in the Kiroro Dashboard are allowed. This prevent unauthorized usage of your infrastructure.

Identity Sovereignty

Users log into the unified Kiroro environment. This protects user credentials while providing developers with secure, authenticated social identities.


For AI assistants and LLM integrations:

/llms.txt