> ## Documentation Index
> Fetch the complete documentation index at: https://docs.b3.fun/llms.txt
> Use this file to discover all available pages before exploring further.

# B3 SDK

> A comprehensive TypeScript SDK for AnySpend cross-chain operations and B3 Global Accounts authentication. Provides both React components for easy integration and headless TypeScript services for custom implementations.

<img src="https://mintcdn.com/npclabs/T8myXHRpwbznxu_Y/images/b3-banner.png?fit=max&auto=format&n=T8myXHRpwbznxu_Y&q=85&s=596d1876967f909ed18e495ac2c4a3d5" alt="B3 SDK" className="w-full rounded-xl" width="600" height="120" data-path="images/b3-banner.png" />

## What is the B3 SDK?

The B3 SDK (`@b3dotfun/sdk`) is a unified TypeScript SDK that provides everything you need to build applications on the B3 ecosystem. It combines powerful cross-chain payment infrastructure with seamless authentication, all wrapped in developer-friendly React components and headless services.

## Architecture

The SDK is organized into focused modules designed for maximum flexibility and ease of use:

<CardGroup cols={2}>
  <Card title="AnySpend Module" icon="arrows-right-left" href="/anyspend/introduction">
    Cross-chain execution engine for payments, swaps, and NFT minting across multiple blockchains.
  </Card>

  <Card title="Global Account Module" icon="user" href="/sdk/global-account/introduction">
    B3 Global Accounts authentication and user management with social login and session keys.
  </Card>
</CardGroup>

### Module Structure

Each module contains organized, purpose-built components:

* **`react/`** - React components and hooks for easy integration
* **`services/`** - Headless TypeScript services for custom implementations
* **`types/`** - Comprehensive TypeScript definitions
* **`utils/`** - Utility functions and helpers
* **`constants/`** - Configuration and constants

## Platform Support

| Feature         | React Web | React Native | Headless |
| --------------- | --------- | ------------ | -------- |
| AnySpend        | ✅         | ❌            | ✅        |
| Global Accounts | ✅         | ✅            | ✅        |
| Shared Utils    | ✅         | ✅            | ✅        |

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm install @b3dotfun/sdk
  ```

  ```bash yarn theme={null}
  yarn add @b3dotfun/sdk
  ```

  ```bash pnpm theme={null}
  pnpm add @b3dotfun/sdk
  ```
</CodeGroup>

### CSS Styles

Import the default styles for the best visual experience:

```typescript theme={null}
import "@b3dotfun/sdk/index.css";
```

## Quick Start

### Cross-Chain Payments with AnySpend

```tsx theme={null}
import { AnySpend } from "@b3dotfun/sdk/anyspend/react";

function PaymentPage() {
  return <AnySpend mode="page" />;
}
```

### Authentication with Global Accounts

```tsx theme={null}
import { B3Provider, SignInWithB3 } from "@b3dotfun/sdk/global-account/react";

function App() {
  return (
    <B3Provider environment="production" partnerId="your-awesome-partner-id">
      <SignInWithB3
        provider={{ strategy: "google" }}
        partnerId="your-partner-id"
        onLoginSuccess={(globalAccount) => {
          console.log("Authenticated:", globalAccount);
        }}
      />
    </B3Provider>
  );
}
```

### NFT Minting

```tsx theme={null}
import { AnySpendNFTButton } from "@b3dotfun/sdk/anyspend/react";

function NFTMinting() {
  const nftContract = {
    address: "0x9c275ff1634519E9B5449ec79cd939B5F900564d",
    chainId: 8333,
    name: "Example NFT Collection",
    imageUrl: "https://example.com/nft.jpg",
    price: "1000000000000000000", // 1 ETH in wei
    currency: { symbol: "ETH", decimals: 18 }
  };

  return (
    <AnySpendNFTButton
      nftContract={nftContract}
      recipientAddress="0x..."
    />
  );
}
```

## Key Features

### Universal Payment Infrastructure

<CardGroup cols={2}>
  <Card title="Any Token Payments" icon="coins">
    Accept payments in any cryptocurrency with automatic conversion to your preferred token.
  </Card>

  <Card title="Cross-Chain Swaps" icon="arrow-right-arrow-left">
    Enable seamless token swaps across 20+ supported blockchains with optimal routing.
  </Card>

  <Card title="NFT Minting" icon="image">
    One-click NFT minting buttons that accept payments in any token from any chain.
  </Card>

  <Card title="Fiat Onramps" icon="credit-card">
    Integrated fiat-to-crypto onramps for users without existing cryptocurrency.
  </Card>
</CardGroup>

### Seamless Authentication

<CardGroup cols={2}>
  <Card title="Social Login" icon="users">
    Google, Discord, and other social providers with instant onboarding.
  </Card>

  <Card title="Session Keys" icon="key">
    Secure session management with granular permissions for enhanced UX.
  </Card>

  <Card title="Cross-Platform Identity" icon="globe">
    Single identity that works across all B3 applications and games.
  </Card>

  <Card title="Smart Accounts" icon="wallet">
    Built-in smart account abstraction for gasless transactions.
  </Card>
</CardGroup>

## Headless TypeScript Services

For developers who need maximum control, all functionality is available through headless services:

### AnySpend Services

```typescript theme={null}
import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";

// Get quote for cross-chain swap
const quote = await anyspendService.getQuote({
  srcChain: 1,
  dstChain: 8333,
  srcTokenAddress: "0x...",
  dstTokenAddress: "0x...",
  srcAmount: "1000000",
  recipientAddress: "0x...",
  type: "swap"
});

// Create and execute order
const order = await anyspendService.createOrder({
  // ... order parameters
});
```

### Global Account Services

```typescript theme={null}
import { authenticate } from "@b3dotfun/sdk/global-account/app";

// Authenticate user
const authResult = await authenticate(
  "access-token",
  "identity-token"
);

if (authResult) {
  console.log("Authentication successful:", authResult);
}
```

## Support & Community

<CardGroup cols={3}>
  <Card title="Developer Support" icon="handshake" href="https://b3builders.typeform.com/bsmntdevelopers">
    Get help integrating the B3 SDK into your project.
  </Card>

  <Card title="Discord Community" icon="discord" href="https://discord.gg/b3dotfun">
    Join the B3 developer community for support and discussions.
  </Card>

  <Card title="GitHub" icon="github" href="https://github.com/b3-fun/b3">
    View source code, report issues, and contribute to the SDK.
  </Card>
</CardGroup>

## What's Next?

1. [**Install the SDK**](#installation) and import the styles
2. [**Set up AnySpend**](/anyspend/introduction) for cross-chain payments
3. [**Configure Global Accounts**](/sdk/global-account/authentication) for user authentication
4. [**Explore examples**](/anyspend/examples) and implementation patterns
5. [**Join the community**](https://discord.gg/b3dotfun) for support and updates

The B3 SDK provides everything you need to build the next generation of cross-chain applications with seamless user experiences. Start building today!
