Extension Wallet
Integration
BITCOIN Network
Provider

Provider

Cosmostation browser extension supports multiple blockchains and exposes chain-specific providers for dApp integration. This page explains how to integrate Cosmostation Extension with Bitcoin (BTC).

Cosmostation’s BTC provider implements the BTCProvider specification from @tomo-inc/tomo-wallet-provider, so it can be used in a Babylon-friendly way through the Tomo Wallet SDK.

You can integrate BTC in two ways:

  • Tomo Wallet SDK (@tomo-inc/wallet-connect-sdk) (recommended for Tomo/Babylon integrations)
  • Vanilla JavaScript via the injected provider (window.cosmostation.bitcoin)

Tomo Wallet SDK (@tomo-inc/wallet-connect-sdk)

Tomo’s Bitcoin Provider documentation shows a standard integration pattern: open the Bitcoin connection modal, check connection state, and then access bitcoinProvider from the provider set.

Example (connect + get provider)

import {
  useTomoProviders,
  useTomoModalControl,
  useTomoWalletConnect,
  useTomoWalletState,
} from '@tomo-inc/wallet-connect-sdk';
 
// 1) Open the BTC connection modal
const tomoModal = useTomoModalControl();
await tomoModal.open('bitcoin');
 
// 2) Check connection state
const walletState = useTomoWalletState();
const connected = walletState.isConnected;
 
// 3) Get the BTC provider
const providers = useTomoProviders();
const bitcoinProvider = providers.bitcoinProvider;
 
// 4) Disconnect (optional)
const walletConnect = useTomoWalletConnect();
await walletConnect.disconnect();

For full SDK setup and usage patterns, follow Tomo’s “For Babylon” documentation. (docs.tomo.inc (opens in a new tab))


Vanilla JavaScript Integration

If you don’t want to use the Tomo SDK, you can access the injected provider directly.

Accessing the provider

const bitcoin = () => {
  if ('cosmostation' in window) {
    return window.cosmostation.bitcoin;
  }
 
  window.open('https://cosmostation.io/wallet/#extension');
  /**
   * or:
   * window.open(
   *   'https://chrome.google.com/webstore/detail/cosmostation/fpkhgmpbidmiogeglndfbkegfdlnajnf'
   * );
   */
};
 
const provider = bitcoin();

Notes

  • The provider is available only when the Cosmostation extension is installed.
  • Account selection, permissions, and signing confirmations are handled by the wallet UI.

Supported BTCProvider API

Cosmostation’s BTC provider follows the Tomo-style BTCProvider surface (Babylon-friendly wrapper), including account access, balance lookup, PSBT signing, message signing, and network switching. (docs.tomo.inc (opens in a new tab))

CategoryMethodDescription
ConnectconnectWallet()Requests wallet connection and returns the connected address list.
IdentitygetWalletProviderName()Returns the provider name (e.g., “Cosmostation”).
IdentitygetWalletProviderIcon()Returns the provider icon (encoded or URL).
AccountgetAccounts()Returns accounts as an array (typically a single selected address).
AccountgetAddress()Returns the currently selected BTC address.
BalancegetBalance()Returns the current balance information for the selected address.
KeysgetPublicKey()Returns the public key (provider-specific encoding).
KeysgetPublicKeyHex()Returns the public key as a hex string.
PSBTsignPsbt(psbtHex)Signs a single PSBT (hex) and returns the signed result.
PSBTsignPsbts(psbtsHexes)Signs multiple PSBTs (hex array) and returns signed results.
MessagesignMessage(message, type?)Signs a message using ecdsa (default) or bip322-simple.
MessagesignMessageBIP322(message)Convenience wrapper for bip322-simple signing.
NetworkgetNetwork()Returns the current BTC network (e.g., mainnet/testnet/signet). (docs.tomo.inc (opens in a new tab))
NetworkswitchNetwork(network)Switches the wallet network and returns the updated network. (docs.tomo.inc (opens in a new tab))
SendsendBitcoin(to, satAmount)Sends BTC (in satoshis) and returns the tx id.
BroadcastpushTx(txHex)Broadcasts a raw transaction hex and returns the tx id.

Further Reading