Download

arrow_down

Developer sercices

arrow_down

More

arrow_down
activityactivityactivityactivity
  • themelight
  • languageIcon

  • menu
Skip to Content

Cosmos

Wallet Standard

MethodParametersReturn ValueDescription
connectchainId?: stringPromise<void>Connect to the wallet
disconnectNonePromise<void>Disconnect from the wallet
getAccountchainId: stringPromise<{address: string, pubkey: Uint8Array}>Get account info for the specified chain
getOfflineSignerAutochainId: stringPromise<OfflineAminoSigner | OfflineDirectSigner>Get an offline signer
signArbitrarychainId: string, signer: string, data: stringPromise<StdSignature>Sign arbitrary data
signDirectchainId: string, signer: string, signDoc: SignDocPromise<DirectSignResponse>Direct signing
signAminochainId: string, signer: string, signDoc: StdSignDocPromise<AminoSignResponse>Amino signing
sendTxchainId: string, tx: Uint8Array, mode: BroadcastModePromise<Uint8Array>Send transaction

Supported Shains

ChainChain IDDescription
MANTRAmantra-mainnet-1A DeFi and staking protocol in the Cosmos ecosystem, focusing on compliant finance and cross-chain asset liquidity management.
Celestiacelestia-mainnet-1Pioneering modular blockchain specializing in data availability layers to provide scalable infrastructure for other chains.
Coreumcoreum-mainnet-1Enterprise-grade blockchain supporting WASM smart contracts, emphasizing interoperability and financial compliance.
Sagasaga-mainnet-1Application-specific chain protocol for gaming/entertainment, offering one-click chain deployment and horizontal scalability.
Cosmos Hubcosmoshub-4Core hub of the Cosmos ecosystem, enabling cross-chain interoperability via IBC protocol. Native token: ATOM.
Xionxion-mainnet-1User-centric universal abstraction layer, providing end-to-end abstraction for accounts, fees, and interactions.
Nillionnil-chain-mainnet-1Privacy-focused compute network leveraging non-blockchain architecture (NMC) for high-speed confidential data processing.
Osmosisosmosis-1Leading DEX in Cosmos, specializing in cross-chain liquidity and innovative AMM mechanisms.

Connect to Bitget Wallet

Provider

const provider = window.bitkeep && window.bitkeep.keplr;

Account

get account info, such as address or public and so on

Usage

getKey(chainId: string): Promise<{ // Name of the selected Wallet. name: string; algo: string; pubKey: Uint8Array; address: Uint8Array; bech32Address: string; }>

Try It

Loading live editor...

Enable

Usage

enable(chainId: string): Promise<void>

Try It

Loading live editor...

Account Change Event

监听账户变化事件。

Usage

provider.on('keplr_keystorechange', () => { console.log('账户已变化') })

Sign Message

  • Signs arbitrary data using the specified account and chain ID.
  • Commonly used for off-chain signing (e.g., user authentication or authorization).

Usage

interface StdSignature { signature: string; // The actual signature string (typically base64-encoded) pub_key: { type: string; // The type of public key (e.g., "tendermint/PubKeySecp256k1") value: string; // The base64-encoded public key value }; } /** * Verifies a previously generated signature against the original data and signer. * @param chainId - The chain ID used during signing * @param signer - The Bech32 address of the signer * @param data - The original data that was signed * @param signature - The StdSignature object to verify * @returns A promise that resolves to a boolean indicating whether the signature is valid */ function verifyArbitrary( chainId: string, signer: string, data: string | Uint8Array, signature: string ): Promise<boolean> { // Implementation goes here } /** * @param chainId - The chain ID (e.g., "cosmoshub-4") * @param signer - The Bech32 address of the account performing the signature * @param data - The raw data to be signed (as a string or byte array) * @returns Promise<StdSignature> - A promise that resolves to a StdSignature object containing the signature and public key */ function signArbitrary( chainId: string, signer: string, data: string | Uint8Array ): Promise<StdSignature> { // Implementation goes here }

Try It import from “@codes/Cosmos/SignArbitrary”;

Loading live editor...

Transaction

SignAmino

signAmino is a method used to sign transactions using the Amino JSON format, which is a legacy serialization format used in the Cosmos ecosystem (especially with older Cosmos SDK versions and wallets like Keplr).

Usage

// Represents a single unit of currency and its amount interface Coin { denom: string; // The unit of currency (e.g., "uatom") amount: string; // The amount (as a string to support large integers) } // Represents the fee information for a transaction interface StdFee { amount: readonly Coin[]; // Array of fee amounts gas: string; // Gas limit granter?: string; // (Optional) Address of the fee granter payer?: string; // (Optional) Address of the fee payer } // Represents an Amino message used in signing documents interface AminoMsg { type: string; // The type of the message (e.g., "cosmos-sdk/MsgSend") value: any; // The actual message content (object structure depends on the message type) } // Represents the full document to be signed in Amino JSON format interface StdSignDoc { chain_id: string; // Chain ID account_number: string; // Account number of the signer sequence: string; // Sequence number for preventing replay fee: StdFee; // Fee information msgs: readonly AminoMsg[]; // Array of messages memo: string; // Optional memo field for notes timeout_height?: string; // (Optional) Timeout height for transaction expiration } interface SignAminoResponse { signed: StdSignDoc, signature: { signature: string, pub_key: { type: string, value: string } } } function signAmino( chainId: string, signer: string, signDoc: StdSignDoc ): Promise<SignAminoResponse>

Try It

Loading live editor...

SignDirect

Params

signDirect(chainId:string, signer:string, signDoc: { /** SignDoc bodyBytes */ bodyBytes?: Uint8Array | null; /** SignDoc authInfoBytes */ authInfoBytes?: Uint8Array | null; /** SignDoc chainId */ chainId?: string | null; /** SignDoc accountNumber */ accountNumber?: Long | null; }): Promise<DirectSignResponse>

Usage

import { TxBody, AuthInfo, SignerInfo, Fee } from 'cosmjs-types/cosmos/tx/v1beta1/tx' import {MsgSend} from 'cosmjs-types/cosmos/bank/v1beta1/tx' import {Any} from 'cosmjs-types/google/protobuf/any' function getBodyBytes(from, to, v) { const msgSend = MsgSend.fromPartial({ fromAddress: from, toAddressL: to, amount: [{ denom: "uosmo", amount: v}] }); const msgSendAny = Any.fromPartial({ typeUrl: "/cosmos.bank.v1beta1.MsgSend", value: MsgSend.encode(msgSend).finish() }); const txBody = TxBody.fromPartial({ messages: [msgSendAny], memo: "test", timeoutHeight: '0',nonCriticalExtensionOptions: [] }); return TxBody.encode(txBody).finish(); } function getAuthInfoBytes(pubKey, sequence) { const pubKeyAny = Any.fromPartial({ typeUrl: '/cosmos.crypto.secp256k1.PubKey', value: pubKey }) const signerInfo = SignerInfo.fromPartial({ publicKey: pubKeyAny, modeInfo: { single: { mode: 1 } }, sequence: sequence }) const feeValue = Fee.fromPartial({ amount: [{ denom: "uosmo", amount: "600" }], gasLimit: '200000', "granter": "", "payer": "" }) const authInfo = AuthInfo.fromPartial({ signerInfos: [signerInfo], fee: feeValue }) return AuthInfo.encode(authInfo).finish() } interface SignAminoResponse { signed: StdSignDoc, signature: { signature: string, pub_key: { type: string, value: string } } } const signDoc = { bodyBytes: getBodyBytes(), authInfoBytes: authInfoBytes(), chainId: 'osmosis-1', accountNumber: '' // } function signDirect( chainId: string, signer: string, signDoc ): Promise<SignAminoResponse>

Try It

Loading live editor...

SignDirectAux

SignDirectAux interface

AttributeTypeDescription
bodyBytesUint8ArrayProtobuf serialized representation of TxBody, matching TxRaw (required)
chainIdstringUnique identifier of the target chain to prevent signature replay attacks (required)
accountNumberbigintAccount number in the state (required)

signDirectAux is a variant signing method API. It allows the wallet to sign a transaction but does not return a complete signature object. Instead, it returns partial signature data. This is particularly useful for multi-signature (multi-sig) accounts, as they require multiple different signers to sign the transaction separately before combining the signatures.

Similar to CosmJS OfflineDirectSigner’s signDirect, but bitkeep signDirect requires chain-id as a mandatory parameter. Signs Proto-encoded StdSignDoc.

sendTx

Request Transaction Broadcast

sendTx( chainId: string, tx: Uint8Array, mode: BroadcastMode ): Promise<Uint8Array>;
Last updated on