Skip to content

BitBadgesSigningClient provides a wallet-agnostic interface for signing and broadcasting transactions on the BitBadges blockchain.

Defined in: packages/bitbadgesjs-sdk/src/signing/BitBadgesSigningClient.ts:85

BitBadgesSigningClient provides a wallet-agnostic interface for signing and broadcasting transactions on the BitBadges blockchain.

It supports both Cosmos wallets (Keplr, Leap, etc.) and EVM wallets (MetaMask via ethers.js) through the adapter pattern.

Example

typescript
// With a Cosmos wallet (Keplr)
const adapter = await GenericCosmosAdapter.fromKeplr('bitbadges-1');
const client = new BitBadgesSigningClient({ adapter });

const result = await client.signAndBroadcast([
  MsgTransferBadges.create({ ... }).toProto()
]);

// With an EVM wallet (ethers.js)
const provider = new BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const adapter = await GenericEvmAdapter.fromSigner(signer);
const client = new BitBadgesSigningClient({ adapter });

const result = await client.signAndBroadcast([msg]); // Uses precompile path

Constructors

Constructor

new BitBadgesSigningClient(options): BitBadgesSigningClient

Defined in: packages/bitbadgesjs-sdk/src/signing/BitBadgesSigningClient.ts:105

Create a new BitBadgesSigningClient.

Parameters

options

SigningClientOptions

Configuration options for the client

Returns

BitBadgesSigningClient

Throws

Error if EVM adapter is used and MetaMask is on wrong network

Accessors

address

Get Signature

get address(): string

Defined in: packages/bitbadgesjs-sdk/src/signing/BitBadgesSigningClient.ts:149

Get the BitBadges address (bb-prefixed) for this client.

Returns

string


chainType

Get Signature

get chainType(): "evm" | "cosmos"

Defined in: packages/bitbadgesjs-sdk/src/signing/BitBadgesSigningClient.ts:161

Get the chain type from the adapter.

Returns

"evm" | "cosmos"


config

Get Signature

get config(): NetworkConfig

Defined in: packages/bitbadgesjs-sdk/src/signing/BitBadgesSigningClient.ts:142

Get the network configuration.

Returns

NetworkConfig


evmChainId

Get Signature

get evmChainId(): number

Defined in: packages/bitbadgesjs-sdk/src/signing/BitBadgesSigningClient.ts:175

Get the EVM chain ID being used.

Returns

number

Methods

clearCache()

clearCache(): void

Defined in: packages/bitbadgesjs-sdk/src/signing/BitBadgesSigningClient.ts:262

Clear the cached account info. Call this after transactions to force a refresh.

Returns

void


getAccountInfo()

getAccountInfo(forceRefresh?): Promise<AccountInfo>

Defined in: packages/bitbadgesjs-sdk/src/signing/BitBadgesSigningClient.ts:200

Get account information from the blockchain. Results are cached to minimize RPC calls.

Parameters

forceRefresh?

boolean = false

Force a refresh from the chain instead of using cache

Returns

Promise<AccountInfo>

Account information including accountNumber, sequence, and publicKey


signAndBroadcast()

signAndBroadcast(messages, options?): Promise<BroadcastResult>

Defined in: packages/bitbadgesjs-sdk/src/signing/BitBadgesSigningClient.ts:521

Sign and broadcast a transaction.

Parameters

messages

TransactionMessage[]

Messages to include in the transaction

options?

SignAndBroadcastOptions

Signing and broadcast options

Returns

Promise<BroadcastResult>

Broadcast result including transaction hash


simulate()

simulate(messages, options?): Promise<SimulateResult>

Defined in: packages/bitbadgesjs-sdk/src/signing/BitBadgesSigningClient.ts:285

Simulate a transaction to estimate gas usage.

Parameters

messages

TransactionMessage[]

Messages to include in the transaction

options?

Optional memo

gasMultiplier?

number

memo?

string

Returns

Promise<SimulateResult>

Simulation result with gas estimates


simulateAndReview()

simulateAndReview(messages, options?): Promise<SimulateAndReviewResult>

Defined in: packages/bitbadgesjs-sdk/src/signing/BitBadgesSigningClient.ts:471

Simulate a transaction and return parsed event data with net balance changes.

This combines gas estimation with full event parsing, giving a complete preview of what the transaction will do (coin transfers, badge transfers, IBC transfers, fees) before signing.

For Cosmos wallets, events come from the standard simulate endpoint. For EVM wallets, a separate Cosmos-style simulation is run to obtain events (since EVM estimateGas does not return Cosmos events).

Parameters

messages

TransactionMessage[]

Messages to include in the transaction

options?

Optional memo and txsInfo for IBC transfer detection

memo?

string

txsInfo?

TxMessageInfo[]

Returns

Promise<SimulateAndReviewResult>

Full simulation result with parsed events and net changes

Example

typescript
const review = await client.simulateAndReview([msg], {
  txsInfo: [{ type: 'MsgTransferBadges', msg: { ... } }]
});

console.log('Gas:', review.gasUsed);
console.log('Coin changes:', review.netChanges.coinChanges);
console.log('Badge changes:', review.netChanges.badgeChanges);

Edit this page on GitHub