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:87

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
import { BitBadgesSigningClient, GenericCosmosAdapter, GenericEvmAdapter, MsgTransferTokens } from 'bitbadges';

const adapter = await GenericCosmosAdapter.fromKeplr('bitbadges-1');
// For an EVM wallet, replace the adapter above with:
// const adapter = await GenericEvmAdapter.fromBrowserWallet({ expectedChainId: 50024 });
const client = new BitBadgesSigningClient({ adapter });
const msg = new MsgTransferTokens({
  creator: client.address,
  collectionId: '1',
  transfers: [{
    from: client.address,
    toAddresses: ['bb1py4mfpg6uf59qkyzg0nmau322c5873eeysp5ue'],
    balances: [{ amount: '1', tokenIds: [{ start: '1', end: '1' }], ownershipTimes: [{ start: '1', end: '18446744073709551615' }] }]
  }]
});
const result = await client.signAndBroadcast([msg]);
console.log(result.success ? result.txHash : result.error);

Constructors

Constructor

new BitBadgesSigningClient(options): BitBadgesSigningClient

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

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:151

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

Returns

string


chainType

Get Signature

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

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

Get the chain type from the adapter.

Returns

"cosmos" | "evm"


config

Get Signature

get config(): NetworkConfig

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

Get the network configuration.

Returns

NetworkConfig


evmChainId

Get Signature

get evmChainId(): number

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

Get the EVM chain ID being used.

Returns

number

Methods

clearCache()

clearCache(): void

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

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:202

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:526

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:287

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:476

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
import type { BitBadgesSigningClient, MsgTransferTokens } from 'bitbadges';
declare const client: BitBadgesSigningClient; // configured with a wallet adapter
declare const msg: MsgTransferTokens<bigint>; // transfer to simulate
const review = await client.simulateAndReview([msg], {
  txsInfo: [{ type: 'MsgTransferTokens', msg: msg.toJson() }]
});

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

Edit this page on GitHub