Wallet Integration
The SDK supports three browser wallets (Keplr, Leap, BWICK Wallet) and a mnemonic-based connection for development. All return a standard WalletConnection interface.
Wallet Modal (Recommended)
The easiest way to connect a wallet in a browser dApp. Shows a selection dialog with all available wallets:
import { showWalletModal } from "@bwick-chain/sdk" ;
const wallet = await showWalletModal ({
rpcEndpoint: "https://rpc.bwick.fun" ,
restEndpoint: "https://rest.bwick.fun" , // Optional
chainId: "bwick-1" , // Optional
suggestChain: true , // Auto-register chain in wallet
});
if ( wallet ) {
console . log ( "Connected:" , wallet . type ); // "keplr" | "leap" | "bwick"
console . log ( "Address:" , wallet . address ); // "bwick1..."
// wallet.signer is ready for signing
}
The modal automatically detects which wallets are installed and only shows available options.
Individual Wallet Connections
Connect to a specific wallet directly:
Keplr
import { connectKeplr } from "@bwick-chain/sdk" ;
const wallet = await connectKeplr ({
rpcEndpoint: "https://rpc.bwick.fun" ,
restEndpoint: "https://rest.bwick.fun" ,
chainId: "bwick-1" ,
suggestChain: true , // Register bwickchain in Keplr if not already added
});
console . log ( wallet . address );
Leap
import { connectLeap } from "@bwick-chain/sdk" ;
const wallet = await connectLeap ({
rpcEndpoint: "https://rpc.bwick.fun" ,
restEndpoint: "https://rest.bwick.fun" ,
suggestChain: true ,
});
BWICK Wallet
import { connectBWICK } from "@bwick-chain/sdk" ;
const wallet = await connectBWICK ({
rpcEndpoint: "https://rpc.bwick.fun" ,
restEndpoint: "https://rest.bwick.fun" ,
suggestChain: true ,
});
Wallet Detection
Check which wallets are available before connecting:
import {
isKeplrAvailable ,
isLeapAvailable ,
isBWICKAvailable ,
getAvailableWallets ,
} from "@bwick-chain/sdk" ;
if ( isKeplrAvailable ()) {
console . log ( "Keplr extension detected" );
}
if ( isLeapAvailable ()) {
console . log ( "Leap extension detected" );
}
if ( isBWICKAvailable ()) {
console . log ( "BWICK Wallet extension detected" );
}
// Get all available wallet types
const wallets = getAvailableWallets ();
// ["keplr", "leap", "bwick"] -- only includes installed wallets
Direct Connection (Development)
For Node.js scripts, tests, and development, connect with a mnemonic:
import { connectDirect } from "@bwick-chain/sdk" ;
const wallet = await connectDirect ({
rpcEndpoint: "https://rpc.bwick.fun" ,
chainId: "bwick-1" ,
mnemonic: "your twelve word mnemonic phrase ..." ,
prefix: "bwick" ,
});
Never use connectDirect in production browser code. Mnemonics should only be used in server-side scripts and development environments.
WalletConnection Interface
All connection methods return the same interface:
interface WalletConnection {
type : "keplr" | "leap" | "bwick" | "direct" ;
address : string ; // The connected bwick1... address
signer : OfflineSigner ; // CosmJS signer for transactions
disconnect () : void ; // Clean up connection
}
Use wallet.signer with createContractClient() or other SDK transaction functions:
import { createContractClient , executeContract } from "@bwick-chain/sdk" ;
const contractClient = await createContractClient (
{ rpcEndpoint: "https://rpc.bwick.fun" },
wallet
);
await executeContract (
contractClient ,
wallet . address ,
"bwick1...contract" ,
{ some_action: {} }
);
Chain Registration
When suggestChain: true is set, the SDK automatically registers bwickchain in the wallet if it hasn’t been added before. This uses the chain info from the SDK:
import { getBWICKChainInfo } from "@bwick-chain/sdk" ;
const chainInfo = getBWICKChainInfo ();
// Returns full chain registration info (chainId, bech32 prefix, currencies, etc.)
Disconnecting
Always clean up wallet connections when done:
In React applications, call disconnect() in cleanup effects or when the user logs out.
Next Steps
Transactions Sign and broadcast transactions
Queries Read chain data without a wallet