Global Wallet Native API
Direct API for interacting with global wallets without SDK dependencies
The Global Wallet Native API provides a direct interface for interacting with and managing global wallets without requiring any wallet SDK. This API is designed for:
- App developers who want to integrate global wallet functionality
- Wallet developers who need to create custom wallet interfaces
Quick Start
The API is available through the @dynamic-labs/global-wallet-client/features
entry point. Here’s a simple example to get started:
Implementation Options
When creating your global wallet package, you have two implementation approaches:
1. Native API Interface (Recommended)
This approach leverages the @dynamic-labs/global-wallet-client
package to re-export all native APIs through the features
entry point. Benefits include:
- Simpler maintenance
- Automatic feature updates
- Consistent API across the ecosystem
To implement this approach, follow the package creation guide.
2. Custom Interface
You can create a custom interface using the Global Wallet Native API. This gives you complete control over the API design:
Complete Integration Example
Let’s walk through a complete React integration example using a fictional wallet called “Droplet”:
Provider Integration
Viem Integration
Ethers.js Integration
API Reference
Core Methods
connect
Connects the global wallet to your dapp via a pop-up interface.
Parameters:
client
: GlobalWalletClient – The global wallet client instance
Returns:
Promise<Array<BaseWallet>>
– List of connected wallet objects
disconnect
Disconnects the global wallet and emits a disconnect event.
Parameters:
client
: GlobalWalletClient – The global wallet client instance
Wallet Management
getEthereumWallets
Retrieves all connected Ethereum wallets.
Parameters:
client
: GlobalWalletClient – The global wallet client instance
Returns:
Array<BaseWallet>
– Array of Ethereum wallets
getSolanaWallets
Retrieves all connected Solana wallets.
Parameters:
client
: GlobalWalletClient – The global wallet client instance
Returns:
Array<BaseWallet>
– Array of Solana wallets
Network Management
getSupportedEthereumNetworks
Returns supported Ethereum networks.
Parameters:
client
: GlobalWalletClient – The global wallet client instance
Returns:
Array<{ chainId: number; rpcUrl?: string }>
– Supported networks
getWalletNetwork
Returns the current network for a specific wallet.
Parameters:
wallet
: BaseWallet – The wallet to check
Returns:
number | string | null
– Network ID or name
Utility Methods
isEthereumWallet
Checks if a wallet is Ethereum-based.
Parameters:
wallet
: BaseWallet – The wallet to check
Returns:
boolean
– true if Ethereum-based
isSolanaWallet
Checks if a wallet is Solana-based.
Parameters:
wallet
: BaseWallet – The wallet to check
Returns:
boolean
– true if Solana-based
onEvent
Attaches an event listener to the global wallet client.
Parameters:
client
: GlobalWalletClient – The global wallet client instanceeventName
: keyof ClientEventEmitterEvents – Event namecallback
: Function – Event handler
Returns:
VoidFunction
– Unsubscribe function
signMessage
Signs a message using the wallet.
Parameters:
wallet
: BaseWallet – The wallet to usemessage
: string – Message to sign
Returns:
Promise<{ signature: string; signedMessage: string }>
– Signature details
switchNetwork
Switches an Ethereum wallet’s network.
Parameters:
wallet
: BaseWallet – The wallet to switchnetworkId
: number – Target network ID