Bitcoin Provider (Beta)

The Tomo Telegram SDK provides a Bitcoin Provider for sending transactions. Below are methods that developers can use with our Bitcoin provider.

// get provider
const bitcoin = window.tg_tomo_btc;

Currently, Bitcoin provider supports the following address type

type BTCNetworkType = 'MAINNET' | 'TESTNET' | 'SIGNET';
type IBtcAddressType = 'bitcoinP2Wpkh' | 'bitcoinP2Sh' | 'bitcoinP2Tr' | 'bitcoinP2Pkh';
const btcAddressTypeMaps: IBtcAddressType[];

Connect with the Wallet

Before using the provider, the user needs to log in to the wallet through the modal by following the method:

// connect wallet
await bitcoin?.connectWallet();

Signing Methods

The Tomo Telegram SDK supports two signing methods:

  • btc_signMessage

  • btc_signTransaction

btc_signMessage method is used for siging a transaction that only record a message on-chain through OP_RETURN operation.

 const res = await bitcoin.request({
  method: 'btc_signMessage',
  params: [
    {
      addressType: btcAddressTypeMaps[2],
      message: 'btc sign message',
    },
  ],
});
    return res;

btc_signPsbt allows the user to sign a transaction with hex, and the return value is the signed transaction in hex.

Send Transaction

Using btc_sendTx , the developer can create a simple transfer transaction for the user to authorize and send to a specified network:

Last updated