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.
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:
Module Structure
Each module contains organized, purpose-built components:
react/- React components and hooks for easy integrationservices/- Headless TypeScript services for custom implementationstypes/- Comprehensive TypeScript definitionsutils/- Utility functions and helpersconstants/- Configuration and constants
Platform Support
| Feature | React Web | React Native | Headless |
|---|---|---|---|
| AnySpend | ✅ | ❌ | ✅ |
| Global Accounts | ✅ | ✅ | ✅ |
| Shared Utils | ✅ | ✅ | ✅ |
Installation
npm install @b3dotfun/sdkyarn add @b3dotfun/sdkpnpm add @b3dotfun/sdkCSS Styles
Import the default styles for the best visual experience:
typescriptimport "@b3dotfun/sdk/index.css";
Quick Start
Cross-Chain Payments with AnySpend
tsximport { AnySpend } from "@b3dotfun/sdk/anyspend/react"; function PaymentPage() { return <AnySpend mode="page" />; }
Authentication with Global Accounts
tsximport { 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
tsximport { 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
Seamless Authentication
Headless TypeScript Services
For developers who need maximum control, all functionality is available through headless services:
AnySpend Services
typescriptimport { 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
typescriptimport { 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
What's Next?
- Install the SDK and import the styles
- Set up AnySpend for cross-chain payments
- Configure Global Accounts for user authentication
- Explore examples and implementation patterns
- Join the community 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!