Wallet SDK of Sodax
npm install @sodax/wallet-sdk-reactA comprehensive React Wallet SDK tailored for the Sodax ecosystem that provides unified wallet connectivity across multiple blockchain networks.
- Address and connection state management
- EVM (Arbitrum, Avalanche, Base, BSC, Optimism, Polygon, Sonic, HyperEVM, LightLink, Ethereum, Redbelly, Kaia) ✅
- Sui ✅
- Solana ✅
- Stellar ✅
- Injective ✅
- ICON ✅
``bashUsing npm
npm install @sodax/wallet-sdk-react
Peer Dependencies
This package requires the following peer dependencies:
`json
{
"react": ">=19",
"@tanstack/react-query": "latest"
}
`Quick Start
`typescript
import { SodaxWalletProvider, useXConnectors, useXConnect, useXAccount } from '@sodax/wallet-sdk-react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import type { RpcConfig } from '@sodax/types';// Create a QueryClient instance
const queryClient = new QueryClient();
const rpcConfig: RpcConfig = {
// EVM chains
sonic: 'https://rpc.soniclabs.com',
'0xa86a.avax': 'https://api.avax.network/ext/bc/C/rpc',
'0xa4b1.arbitrum': 'https://arb1.arbitrum.io/rpc',
'0x2105.base': 'https://mainnet.base.org',
'0x38.bsc': 'https://bsc-dataseed1.binance.org',
'0xa.optimism': 'https://mainnet.optimism.io',
'0x89.polygon': 'https://polygon-rpc.com',
// Other chains
'0x1.icon': 'https://ctz.solidwallet.io/api/v3',
solana: 'https://solana-mainnet.g.alchemy.com/v2/your-api-key',
sui: 'https://fullnode.mainnet.sui.io',
'injective-1': 'https://sentry.tm.injective.network:26657',
};
function App() {
return (
);
}
function WalletConnect() {
// Get available connectors for EVM chain
const connectors = useXConnectors('EVM');
// Get connect mutation
const { mutateAsync: connect } = useXConnect();
// Get connected account info
const account = useXAccount('EVM');
return (
{/ Display connected wallet address if connected /}
{account?.address && (
Connected Wallet:
{account.address}
)} {/ Display available connectors /}
{connectors.map((connector) => (
key={connector.id}
onClick={() => connect(connector)}
className="flex items-center gap-2 p-2 border rounded-lg hover:bg-gray-50"
>
src={connector.icon}
alt={connector.name}
width={24}
height={24}
className="rounded-md"
/>
Connect {connector.name}
))}
);
}
`This example demonstrates:
1. Setting up the required providers (
QueryClientProvider and SodaxWalletProvider)
2. Using useXConnectors to get available wallet connectors
3. Using useXConnect to handle wallet connections
4. Using useXAccount to display the connected wallet address
5. A basic UI to display and connect to available wallets
Requirements
- Node.js >= 18.0.0
- React >= 19
- TypeScript
API Reference
$3
SodaxWalletProvider - Main provider component for wallet connectivity$3
useXConnectors - Get available wallet connectors
- useXConnect - Connect to a wallet
- useXAccount - Get account information
- useXDisconnect - Disconnect from a walletuseEvmSwitchChain - Switch between EVM chainsuseXBalances - Fetch token balancesuseXService - Access chain-specific service$3
XAccount - Wallet account type
- XConnection - Wallet connection type
- XConnector - Wallet connector type
- XToken - Cross-chain token type$3
XConnector - Base class for wallet connectors
- EvmXConnector - EVM wallet connector
- SolanaXConnector - Solana wallet connector
- SuiXConnector - Sui wallet connector
- StellarXConnector - Stellar wallet connector
- InjectiveMetamaskXConnector - Injective MetaMask connector
- InjectiveKelprXConnector - Injective Keplr connector
- IconXConnector - ICON wallet connectorContributing
We welcome contributions! Please see our Contributing Guide for details.
Development
`bash
Install dependencies
pnpm installBuild the package
pnpm build Run in development mode
pnpm devRun type checking
pnpm checkTsFormat code
pnpm prettyLint code
pnpm lint
``