The BitBadgesSigningClient provides a streamlined, wallet-agnostic interface for signing and broadcasting transactions. It handles account info fetching, gas estimation, signing, and broadcasting in a single call.
When to Use
Use BitBadgesSigningClient when:
You want a simple, all-in-one signing solution
You don't need fine-grained control over the signing process
You want automatic gas estimation and sequence management
You want automatic retry on sequence mismatch errors
You need full control over the transaction lifecycle
You need to customize the signing flow (e.g., custom fee logic)
You need to handle simulation separately from signing
You're integrating with existing transaction management infrastructure
Installation
The signing client is included in the main SDK:
npminstallbitbadgesjs-sdk
Quick Start
Cosmos Wallet (Keplr, Leap, etc.)
EVM Wallet (MetaMask, etc.)
Server-Side Signing (EVM Path β Recommended)
Building an AI agent or bot? See the AI Agents & Bots section for end-to-end examples, testnet faucet, and MCP tool reference.
Server-side signing uses GenericEvmAdapter which connects to the EVM JSON-RPC endpoint and broadcasts via precompile calls. This is the recommended path for bots, agents, and backend services.
Server-Side Signing (Cosmos Path)
The Cosmos path uses GenericCosmosAdapter with Cosmos-derived addresses and standard signDirect broadcasting. This produces a different address from the same key (Cosmos derivation vs ETH derivation).
Note: The same mnemonic/private key produces different addresses depending on which adapter you use. EVM adapter uses keccak256 (ETH-style) with coin type 60 HD path (m/44'/60'/0'/0/0), while Cosmos adapter uses ripemd160/sha256 with coin type 118 HD path (m/44'/118'/0'/0/0). The default for Keplr and the Cosmos chain registry is coin type 118. Make sure you fund the correct address for your chosen adapter.
Client Options
Network Presets
The SDK provides built-in network configurations via NETWORK_CONFIGS:
Use network presets with optional overrides:
Sign and Broadcast Options
Broadcast Result
Wallet Adapters
GenericCosmosAdapter
For browser wallets (Keplr, Leap, etc.) and server-side Cosmos signing:
GenericEvmAdapter
For browser EVM wallets and server-side signing (recommended for bots/agents):
EVM adapters only support sendEvmTransaction β they do not support signDirect. The BitBadgesSigningClient handles routing automatically based on the adapter type.
EVM Chain ID Validation
You can validate that the wallet is connected to the correct EVM network:
Network Selection
Gas Estimation
By default, the client simulates transactions to estimate gas:
Sequence Management
The client automatically handles account sequence (nonce) management:
import { GenericEvmAdapter, NETWORK_CONFIGS } from 'bitbadgesjs-sdk';
// Validate chain ID when creating adapter
const adapter = await GenericEvmAdapter.fromSigner(signer, {
expectedChainId: NETWORK_CONFIGS['mainnet'].evmChainId, // 50024
});
// Or for local development
const adapter = await GenericEvmAdapter.fromBrowserWallet({
expectedChainId: NETWORK_CONFIGS['local'].evmChainId, // 90123
});
// Throws error if wallet is on wrong network:
// "Wallet is connected to chain X, but expected chain Y. Please switch your wallet to the correct network."
// Mainnet (default)
const client = new BitBadgesSigningClient({
adapter,
network: 'mainnet',
});
// Testnet
const client = new BitBadgesSigningClient({
adapter,
network: 'testnet',
});
// Local development
const client = new BitBadgesSigningClient({
adapter,
network: 'local',
});
// Auto gas estimation (default)
const result = await client.signAndBroadcast(messages);
// Skip simulation, use default gas
const result = await client.signAndBroadcast(messages, {
simulate: false,
});
// Custom fee
const result = await client.signAndBroadcast(messages, {
fee: {
amount: '10000000',
denom: 'ubadge',
gas: '500000',
},
});
const client = new BitBadgesSigningClient({
adapter,
sequenceRetryEnabled: true, // Auto-retry on sequence mismatch (default)
maxSequenceRetries: 3, // Max retries (default)
});
// Cached sequence is incremented after successful transactions
// If sequence mismatch occurs, client will:
// 1. Clear cached account info
// 2. Fetch fresh sequence from chain
// 3. Retry the transaction
// Get account info (cached)
const info = await client.getAccountInfo();
console.log(info.address, info.accountNumber, info.sequence);
// Force refresh from chain
const freshInfo = await client.getAccountInfo(true);
// Clear cache manually
client.clearCache();