Skip to content

GenericCosmosAdapter provides wallet adapter functionality for Cosmos signing.

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:162

GenericCosmosAdapter provides wallet adapter functionality for Cosmos signing.

Supports both browser wallets (Keplr, Leap, Cosmostation) and server-side signing with mnemonic or private key.

Example

typescript
// Browser wallet (Keplr)
const adapter = await GenericCosmosAdapter.fromKeplr('bitbadges-1');

// Browser wallet (Leap)
const adapter = await GenericCosmosAdapter.fromLeap('bitbadges-1');

// Server-side with mnemonic
const adapter = await GenericCosmosAdapter.fromMnemonic('word1 word2 ...', 'bitbadges-1');

// Server-side with private key
const adapter = await GenericCosmosAdapter.fromPrivateKey('0x...', 'bitbadges-1');

// Use with signing client
const client = new BitBadgesSigningClient({ adapter });

Extends

Implements

Properties

address

readonly address: string

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:164

The address managed by this adapter (BitBadges bb-prefixed for Cosmos, 0x for EVM)

Implementation of

WalletAdapter.address

Overrides

BaseWalletAdapter.address


chainType

readonly chainType: "cosmos"

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

The chain type this adapter supports

Implementation of

WalletAdapter.chainType

Overrides

BaseWalletAdapter.chainType

Methods

estimateEvmGas()?

optional estimateEvmGas(tx): Promise<bigint>

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/WalletAdapter.ts:90

Estimate gas for an EVM transaction. Only implemented by EVM wallet adapters with a provider connection.

Parameters

tx

EvmTransaction

Returns

Promise<bigint>

Implementation of

WalletAdapter.estimateEvmGas

Inherited from

BaseWalletAdapter.estimateEvmGas


getPublicKey()

getPublicKey(): Promise<string>

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:347

Get the public key in base64 format. Required for Cosmos transactions (used to build the auth info). Returns empty string for EVM-only adapters.

Returns

Promise<string>

Implementation of

WalletAdapter.getPublicKey

Overrides

BaseWalletAdapter.getPublicKey


sendEvmTransaction()?

optional sendEvmTransaction(tx): Promise<string>

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/WalletAdapter.ts:89

Send an EVM transaction. Only implemented by EVM wallet adapters.

Parameters

tx

EvmTransaction

The EVM transaction to send

Returns

Promise<string>

The transaction hash

Implementation of

WalletAdapter.sendEvmTransaction

Inherited from

BaseWalletAdapter.sendEvmTransaction


signDirect()

signDirect(payload, accountNumber): Promise<SigningResult>

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:351

Sign a transaction using Cosmos SignDirect format. Only implemented by Cosmos wallet adapters.

Parameters

payload

TransactionPayload

The transaction payload containing signBytes

accountNumber

Uint64Like

The account number on the blockchain. Post-v34 accounts get hash-derived numbers above 2^53 — pass the chain's string value or a bigint; never Number() it.

Returns

Promise<SigningResult>

The signature and public key

Implementation of

WalletAdapter.signDirect

Overrides

BaseWalletAdapter.signDirect


signTypedData()?

optional signTypedData(typed): Promise<string>

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/WalletAdapter.ts:91

Sign EIP-712 typed-data with the wallet. Only implemented by EVM wallet adapters; lets BitBadges Cosmos messages be signed via the standard EVM signing flow (eth_signTypedData_v4 / Signer.signTypedData) so any EVM wallet can produce a valid Cosmos transaction signature. Returns a 0x...-prefixed 65-byte hex signature (r || s || v).

Parameters

typed

EIP712TypedData

Returns

Promise<string>

Implementation of

WalletAdapter.signTypedData

Inherited from

BaseWalletAdapter.signTypedData


supportsEvmTransaction()

supportsEvmTransaction(): boolean

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:393

Check if the adapter supports EVM transactions

Returns

boolean

Implementation of

WalletAdapter.supportsEvmTransaction

Overrides

BaseWalletAdapter.supportsEvmTransaction


supportsSignAmino()

supportsSignAmino(): boolean

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:389

Check if the adapter supports Amino signing (legacy)

Returns

boolean

Implementation of

WalletAdapter.supportsSignAmino

Overrides

BaseWalletAdapter.supportsSignAmino


supportsSignDirect()

supportsSignDirect(): boolean

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:385

Check if the adapter supports SignDirect signing

Returns

boolean

Implementation of

WalletAdapter.supportsSignDirect

Overrides

BaseWalletAdapter.supportsSignDirect


supportsSignTypedData()

supportsSignTypedData(): boolean

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

Check if the adapter supports EIP-712 typed-data signing

Returns

boolean

Implementation of

WalletAdapter.supportsSignTypedData

Inherited from

BaseWalletAdapter.supportsSignTypedData


fromBrowserWallet()

static fromBrowserWallet(wallet, chainId, prefix?): Promise<GenericCosmosAdapter>

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:237

Create an adapter from any Keplr-compatible wallet interface.

Parameters

wallet

KeplrLike

A Keplr-compatible wallet instance

chainId

string

The chain ID to connect to

prefix?

string = 'bb'

Optional address prefix (default: 'bb')

Returns

Promise<GenericCosmosAdapter>

A new GenericCosmosAdapter connected to the wallet


fromCosmostation()

static fromCosmostation(chainId): Promise<GenericCosmosAdapter>

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:222

Create an adapter from Cosmostation wallet.

Parameters

chainId

string

The chain ID to connect to

Returns

Promise<GenericCosmosAdapter>

A new GenericCosmosAdapter connected to Cosmostation


fromKeplr()

static fromKeplr(chainId): Promise<GenericCosmosAdapter>

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:196

Create an adapter from Keplr wallet.

Parameters

chainId

string

The chain ID to connect to

Returns

Promise<GenericCosmosAdapter>

A new GenericCosmosAdapter connected to Keplr


fromLeap()

static fromLeap(chainId): Promise<GenericCosmosAdapter>

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:209

Create an adapter from Leap wallet.

Parameters

chainId

string

The chain ID to connect to

Returns

Promise<GenericCosmosAdapter>

A new GenericCosmosAdapter connected to Leap


fromMnemonic()

static fromMnemonic(mnemonic, chainId, options?): Promise<GenericCosmosAdapter>

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:279

Create an adapter from a mnemonic phrase (server-side).

Security Note: Only use in secure server-side environments.

Parameters

mnemonic

string

The BIP-39 mnemonic phrase (12 or 24 words)

chainId

string

The chain ID to use

options?

string | { prefix?: string; }

Optional: prefix string (default 'bb') or options object with prefix

Returns

Promise<GenericCosmosAdapter>

A new GenericCosmosAdapter for server-side signing

Example

typescript
const adapter = await GenericCosmosAdapter.fromMnemonic('word1 word2 ...', 'bitbadges-2');
const client = new BitBadgesSigningClient({ adapter, network: 'testnet' });

fromPrivateKey()

static fromPrivateKey(privateKey, chainId, options?): Promise<GenericCosmosAdapter>

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:297

Create an adapter from a private key (server-side).

Security Note: Only use in secure server-side environments.

Parameters

privateKey

string

The private key (hex string, with or without 0x prefix)

chainId

string

The chain ID to use

options?

string | { prefix?: string; }

Optional: prefix string (default 'bb') or options object with prefix

Returns

Promise<GenericCosmosAdapter>

A new GenericCosmosAdapter for server-side signing


fromWallet()

static fromWallet(wallet, chainId, prefix?): Promise<GenericCosmosAdapter>

Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:257

Parameters

wallet

KeplrLike

chainId

string

prefix?

string = 'bb'

Returns

Promise<GenericCosmosAdapter>

Deprecated

Use fromBrowserWallet instead

Edit this page on GitHub