β οΈ IMPORTANT: IN PROGRESS - This package is currently being updated to fix build issues. Please use with caution.
- β¨ Features
- π Installation
- πββοΈ Quick Start
- π Usage Examples
- π§ API Reference
- βοΈ Configuration
- π° Cost Comparison
- π οΈ Development
- π¦ Package Structure
- π Security Features
- π€ Contributing
- π License
- π Acknowledgments
- π Quick Start β Production Migration
A powerful, multi-platform wallet SDK for React, Next.js, and React Native applications with free, custom social login and support for Rainbow Kit and Wagmi. 100% D-Sports branded with no vendor dependencies.
- π Multi-platform support: Works with React, Next.js, and React Native
- π Custom social login: FREE OAuth integration with Google, Facebook, Twitter, Discord, GitHub, and Apple
- π D-Sports branded: Fully customizable, no vendor lock-in
- π Rainbow Kit compatible: Easy integration with Rainbow Kit's wallet connection UI
- β‘ Wagmi compatible: Full support for Wagmi v1 and v2
- π¨ Customizable UI: Flexible theming and styling options
- π Secure storage: Platform-specific secure storage solutions
- π± Mobile-first: Deep linking and mobile-optimized experience
- π Auto-reconnection: Persistent wallet connections across sessions
- π° Zero cost: No per-user fees or external dependencies
- π― TypeScript: Full TypeScript support with comprehensive type definitions
npm install @d-sports/wallet
# or
yarn add @d-sports/wallet
# or
bun add @d-sports/walletFor Next.js/React:
# No additional dependencies required!For React Native:
npm install react-native-keychain react-native-url-polyfillGet started immediately with D-Sports managed OAuth credentials - no OAuth setup required!
import { createDSportsWalletQuickStart, mainnet, polygon } from '@d-sports/wallet';
// π ONE LINE SETUP - No OAuth configuration needed!
const wallet = createDSportsWalletQuickStart({
projectId: 'your-project-id',
chains: [mainnet, polygon],
metadata: {
name: 'My Awesome App',
description: 'Built with D-Sports Wallet',
url: 'https://my-app.com',
icons: ['https://my-app.com/icon.png']
}
});
// Connect with social login (Google, Facebook, Twitter, Discord, GitHub ready!)
await wallet.connect({ socialLogin: true });
console.log('π Wallet connected with zero OAuth setup!');Perfect for:
- π§ͺ Prototyping and proof of concepts
- π¨βπ» Development and testing
- π Learning and tutorials
- π Getting started quickly
For production apps, set up your own OAuth applications:
import { createDSportsWallet } from '@d-sports/wallet/nextjs';
// Create wallet instance
const wallet = createDSportsWallet({
projectId: 'your-project-id',
chains: [/* your chains */],
environment: 'production', // Validates production config
socialLogin: {
appSecret: 'your-app-secret', // For deterministic key generation
redirectUri: 'https://your-app.com/auth/callback',
providers: {
google: {
clientId: 'your-google-client-id',
},
facebook: {
clientId: 'your-facebook-app-id',
},
twitter: {
clientId: 'your-twitter-client-id',
},
discord: {
clientId: 'your-discord-client-id',
},
},
},
});
// Connect wallet
await wallet.connect();import { createDSportsWallet, setupURLPolyfill } from '@d-sports/wallet/react-native';
// Setup URL polyfill (required for React Native)
setupURLPolyfill();
// Create wallet instance
const wallet = createDSportsWallet({
projectId: 'your-project-id',
chains: [/* your chains */],
socialLogin: {
appSecret: 'your-app-secret',
redirectUri: 'dsports://auth/callback', // Deep link for mobile
providers: {
google: {
clientId: 'your-google-client-id',
},
apple: {
clientId: 'your-apple-client-id',
},
},
},
});
// Connect wallet
await wallet.connect();import { createDSportsWallet } from '@d-sports/wallet';
const wallet = createDSportsWallet({
projectId: 'your-project-id',
chains: [
{
id: 1,
name: 'Ethereum',
network: 'homestead',
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
rpcUrls: {
default: { http: ['https://mainnet.infura.io/v3/your-key'] },
public: { http: ['https://mainnet.infura.io/v3/your-key'] }
}
}
]
});
// Connect to wallet
const account = await wallet.connect();
console.log('Connected account:', account);
// Get wallet state
const state = wallet.getState();
console.log('Wallet state:', state);
// Switch chain
await wallet.switchChain(137); // Polygon
// Disconnect
await wallet.disconnect();import { createDSportsWallet, CustomSocialLoginProvider } from '@d-sports/wallet';
const wallet = createDSportsWallet({
projectId: 'your-project-id',
chains: [/* your chains */],
socialLogin: {
appSecret: 'your-unique-app-secret', // Used for deterministic key generation
redirectUri: 'https://your-app.com/auth/callback',
providers: {
google: {
clientId: 'your-google-oauth-client-id',
},
facebook: {
clientId: 'your-facebook-app-id',
},
twitter: {
clientId: 'your-twitter-oauth-client-id',
},
discord: {
clientId: 'your-discord-oauth-client-id',
},
github: {
clientId: 'your-github-oauth-client-id',
},
},
},
});
// Connect with social login
await wallet.connect({ socialLogin: true });
// Get social login provider
const socialProvider = wallet.getConnector('dsports-wallet').customSocialLoginProvider;
// Login with specific provider
const result = await socialProvider.login('google');
console.log('Social login result:', result);
// Get wallet from social login
const ethersWallet = await socialProvider.getWalletFromSocial(result);
console.log('Generated wallet address:', ethersWallet.address);import { createDSportsRainbowKitConnector } from '@d-sports/wallet';
const connector = createDSportsRainbowKitConnector({
chains: [/* your chains */],
projectId: 'your-project-id',
appName: 'My App',
socialLogin: {
appSecret: 'your-app-secret',
redirectUri: 'https://your-app.com/auth/callback',
providers: {
google: {
clientId: 'your-google-client-id',
},
facebook: {
clientId: 'your-facebook-client-id',
},
},
},
});
// Use with Rainbow Kit
const connectors = [
connector,
// ... other connectors
];import { dsportsWagmiConnector } from '@d-sports/wallet';
const connector = dsportsWagmiConnector({
chains: [/* your chains */],
projectId: 'your-project-id',
socialLogin: {
appSecret: 'your-app-secret',
redirectUri: 'https://your-app.com/auth/callback',
providers: {
google: {
clientId: 'your-google-client-id',
},
},
},
});
// Use with Wagmi
const connectors = [
connector,
// ... other connectors
];interface DSportsWalletOptions {
projectId: string;
chains: Chain[];
socialLogin?: CustomSocialLoginConfig;
theme?: WalletTheme;
metadata?: {
name: string;
description: string;
url: string;
icons: string[];
};
}connect(config?: { socialLogin?: boolean }): Promise<WalletAccount>disconnect(): Promise<void>switchChain(chainId: number): Promise<void>getState(): WalletStateisConnected(): booleangetConnector(id: string): WalletConnector | undefinedaddConnector(connector: WalletConnector): voidremoveConnector(id: string): void
connect: Emitted when wallet connectsdisconnect: Emitted when wallet disconnectsaccountsChanged: Emitted when accounts changechainChanged: Emitted when chain changeserror: Emitted when an error occurs
const {
account,
isConnecting,
isReconnecting,
isDisconnected,
error,
connect,
disconnect,
switchChain,
isConnected
} = useDSportsWallet(wallet);const {
user,
isLoading,
error,
login,
logout
} = useSocialLogin(customSocialLoginProvider);interface CustomSocialLoginConfig {
appSecret?: string; // Used for deterministic wallet generation
redirectUri?: string; // OAuth callback URL
providers: {
[key in SocialProvider]?: {
clientId: string;
clientSecret?: string; // For backend token exchange
};
};
}- Google (
google): OAuth 2.0 - Facebook (
facebook): Facebook Login - Twitter (
twitter): OAuth 2.0 - Discord (
discord): OAuth 2.0 - GitHub (
github): OAuth 2.0 - Apple (
apple): Sign in with Apple
- Go to Google Cloud Console
- Create a new project or select existing
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add your domain to authorized origins
- Copy the Client ID
- Go to Facebook Developers
- Create a new app
- Set up Facebook Login
- Add your domain to valid OAuth redirect URIs
- Copy the App ID
- Go to Twitter Developer Portal
- Create a new app
- Set up OAuth 2.0
- Configure callback URLs
- Copy the Client ID
interface WalletTheme {
colors?: {
primary?: string;
secondary?: string;
background?: string;
text?: string;
border?: string;
};
borderRadius?: number;
fontFamily?: string;
}Create a callback page at your redirectUri to handle OAuth responses:
<!DOCTYPE html>
<html>
<head>
<title>D-Sports Authentication</title>
<style>
body { font-family: Arial, sans-serif; text-align: center; padding: 50px; }
.loading { color: #666; }
.logo { width: 64px; height: 64px; margin: 20px auto; }
</style>
</head>
<body>
<div class="logo">π</div>
<h2>D-Sports Authentication</h2>
<p class="loading">Processing your login...</p>
<script>
// Handle OAuth callback
const urlParams = new URLSearchParams(window.location.search);
const code = urlParams.get('code');
const error = urlParams.get('error');
if (error) {
window.parent.postMessage({
type: 'OAUTH_ERROR',
error: error
}, window.location.origin);
} else if (code) {
// Exchange code for user data (implement your backend logic)
window.parent.postMessage({
type: 'OAUTH_SUCCESS',
payload: {
code,
user: {
id: 'user-id-from-your-backend',
email: 'user@example.com',
name: 'User Name',
avatar: 'https://example.com/avatar.jpg'
},
token: 'access-token-from-your-backend',
expiresAt: Date.now() + 3600000
}
}, window.location.origin);
}
</script>
</body>
</html>import { handleDeepLink } from '@d-sports/wallet/react-native';
// Handle deep link
handleDeepLink('dsports://wallet/connect?connector=dsports-wallet', wallet);| Provider | Cost | Lock-in | Branding |
|---|---|---|---|
| @d-sports/wallet | FREE | β None | π Full D-Sports |
| Web3Auth | $0.05/MAU | β Yes | π Limited |
| Magic | $0.02/MAU | β Yes | π Limited |
| Privy | $0.05/MAU | β Yes | π Limited |
git clone https://github.com/D-Sports-Ecosystem/wallet.git
cd wallet
bun installbun run buildbun testbun run dev: Start development modebun run build: Build all packagesbun run build:core: Build core packagebun run build:nextjs: Build Next.js packagebun run build:react-native: Build React Native packagebun run clean: Clean build artifactsbun run lint: Run ESLintbun run test: Run testsbun run test:watch: Run tests in watch mode
@d-sports/wallet/
βββ core # Core wallet functionality
βββ nextjs # Next.js specific exports
βββ react-native # React Native specific exports
βββ custom-social-login # Custom social login provider
βββ types # TypeScript type definitions- Deterministic Key Generation: Wallets are generated deterministically from social login data
- Secure Storage: Platform-specific secure storage (localStorage, AsyncStorage, Keychain)
- No Private Key Transmission: Keys are generated locally, never sent to servers
- Custom App Secret: Use your own secret for additional security
- OAuth Best Practices: Follows OAuth 2.0 security guidelines
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see the LICENSE file for details.
- ethers.js for Ethereum interactions
- Rainbow Kit for wallet connection UI
- Wagmi for React hooks for Ethereum
- Rollup for module bundling
Made with β€οΈ by the D-Sports team - A free, open-source alternative to expensive wallet providers.
-
Start with Quick Start (5 minutes):
const wallet = createDSportsWalletQuickStart({ projectId: 'your-project-id', chains: [mainnet, polygon] });
-
Create Your OAuth Apps (30 minutes):
-
Switch to Production Config:
const wallet = createDSportsWallet({ projectId: 'your-project-id', chains: [mainnet, polygon], environment: 'production', // Validates config socialLogin: { appSecret: 'your-production-secret', redirectUri: 'https://your-app.com/auth/callback', providers: { google: { clientId: 'your-google-client-id' }, facebook: { clientId: 'your-facebook-app-id' }, // ... other providers } } });
D-Sports provides managed OAuth credentials for instant development:
import { DSportsOAuthService, createQuickStartSocialLogin } from '@d-sports/wallet';
// Get managed credentials
const managed = DSportsOAuthService.getManagedCredentials({
environment: 'development'
});
// Quick start config (auto-generated)
const quickStartConfig = createQuickStartSocialLogin();
// Validate production config
const productionConfig = validateSocialLoginConfig(myConfig, 'production');Managed OAuth includes:
- β Google - Ready to use
- β Facebook - Ready to use
- β Twitter - Ready to use
- β Discord - Ready to use
- β GitHub - Ready to use
β οΈ Apple - Requires individual setup
Benefits:
- π Instant setup - No OAuth configuration
- π‘οΈ Production warnings - Automatic validation
- π Easy migration - Same API, different config
- π Perfect for demos - Show features immediately