Class: GenericCosmosAdapter
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
// 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
readonlyaddress: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
Overrides
chainType
readonlychainType:"cosmos"
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericCosmosAdapter.ts:163
The chain type this adapter supports
Implementation of
Overrides
Methods
estimateEvmGas()?
optionalestimateEvmGas(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
Returns
Promise<bigint>
Implementation of
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
Overrides
BaseWalletAdapter.getPublicKey
sendEvmTransaction()?
optionalsendEvmTransaction(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
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
The transaction payload containing signBytes
accountNumber
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
Overrides
signTypedData()?
optionalsignTypedData(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
Returns
Promise<string>
Implementation of
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()
staticfromBrowserWallet(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()
staticfromCosmostation(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()
staticfromKeplr(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()
staticfromLeap(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()
staticfromMnemonic(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
const adapter = await GenericCosmosAdapter.fromMnemonic('word1 word2 ...', 'bitbadges-2');
const client = new BitBadgesSigningClient({ adapter, network: 'testnet' });fromPrivateKey()
staticfromPrivateKey(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()
staticfromWallet(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