> For the complete documentation index, see [llms.txt](https://docs.tomo.inc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tomo.inc/tomo-sdk/tomo-telegram-sdk/wallet-provider/bitcoin-provider-beta.md).

# 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.

```typescript
// get provider
const bitcoin = window.tg_tomo_btc;
```

Currently, Bitcoin provider supports the following address type

<pre class="language-typescript"><code class="lang-typescript">type BTCNetworkType = 'MAINNET' | 'TESTNET' | 'SIGNET';
<strong>type IBtcAddressType = 'bitcoinP2Wpkh' | 'bitcoinP2Sh' | 'bitcoinP2Tr' | 'bitcoinP2Pkh';
</strong>const btcAddressTypeMaps: IBtcAddressType[];
</code></pre>

## Connect with the Wallet[​](https://docs.uxuy.com/uxuy-connect/guide/#isconnected) <a href="#isconnected" id="isconnected"></a>

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

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

### Signing Methods[​](https://docs.uxuy.com/uxuy-connect/guide/#signing-methods) <a href="#signing-methods" id="signing-methods"></a>

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.&#x20;

```javascript
 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.

```javascript
 const res = await bitcoin.request({
  method: 'btc_signPsbt',
  params: [
    {
      network:'SIGNET',
      addressType: btcAddressTypeMaps[2],
      psbtHex: '0200000000010145430f279a5e63a9bda3761efbf9f49b9ee4d428f5fe4b2bfeae2e7b54ca83f90000000000fdffffff01bdd5070000000000160014a3213c72757d86a33543010ff748f203a544a2810247304402200134cddfacc47b1c84cd64c2f88d8aa0a3384f42c8ec659bb70dcc4ce4571b650220554c085d85aee0f09f45993dfd485d5ca3df3feba49f9195dfbc4e045694ee88012102d207a562f7466bd1be96be8b35c9ca481a907d8cbf4b1e131b072a4878c1178600000000'
    },
  ],
});
    return res;
```

### Send Transaction[​](https://docs.uxuy.com/uxuy-connect/guide/#isconnected) <a href="#isconnected" id="isconnected"></a>

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

```typescript
import { btcAddressTypeMaps } from 'tomo-tg-wallet-sdk';

const res = await bitcoin.request({
  method: 'btc_sendTx',
  params: [
    {
      network: 'SIGNET',
      addressType: btcAddressTypeMaps[2],
      toAddress: toAddr2,
      amount: toValue2,
    },
  ],
});
```
