# About BitTap

Decentralized solutions on Taproot Assets and Lightning Network

The BitTap team aims to build a decentralized infrastructure for applications on [Taproot Assets protocol ](https://docs.lightning.engineering/the-lightning-network/taproot-assets/taproot-assets-protocol)and Lightning Network. Our first product is a decentralized wallet based on the Taproot Assets protocol. This wallet is a truly non-custodial Taproot Assets wallet, addressing the issue of asset centralization by trading platforms and providing users with the same security and user experience like what MetaMask wallet does on Ethereum.


# Custodial vs. Non-Custodial

BitTap Wallet is a non-custodial wallet, which is most likely the world's first non-custodial wallet for Taproot Assets. To understand what issue BitTap wallet solves, let's see following three ways in which secret keys are managed.

## Self-Hosted Mode

<figure><img src="/files/hLwV22EleenaVgXzpCaS" alt=""><figcaption><p>Self-Hosted mode for Taproot Assets</p></figcaption></figure>

In self-hosted mode, users set up their own LND and Tapd nodes, and the secret keys for both BTC and Taproot Assets are generated and managed by LND. Because the LND node is controlled by users themselves, there are no security issues concerning keys. This is actually the decentralized approach of Lightning Network, but the requirements for users are very high.

## Custodial Mode

<figure><img src="/files/v0e0mK7gyRgW1jnUzrDM" alt=""><figcaption><p>Custodial mode  for Taproot Assets</p></figcaption></figure>

Given that the vast majority of users do not have the ability to setup their own nodes and can only use service providers, this is the custodial mode, which is currently the most commonly used solution in the Taproot Assets ecosystem.&#x20;

In custodial mode, numerous users connect to the Tapd and LND nodes of the service provider, and all secret keys are generated and managed by the LND nodes of the service provider. It is an absolutely centralized operation mode, and once the service provider encounters problems, users' assets will face significant risks.

## Non-Custodial Mode

<figure><img src="/files/SppBuJ8GrNrt65UZNuW5" alt=""><figcaption><p>Non-Custodial mode  for Taproot Assets</p></figcaption></figure>

BitTap wallet is implemented in a decentralized approach, in which users still use the service provider's Tapd and LND nodes, but the generation and management of secret keys are on the user's wallet side, not by LND like the other modes do. Users' private keys will not go out of the wallet, and users will only send the signed data back to the service provider to complete transactions.&#x20;

The non-custodial wallet implemented by BitTap can greatly improve the security of users holding Taproot Assets. See the [BitTap technical architecture](/dex-product/overview#architecture) for how we do it.


# Off-Chain Proof

We know that the Taproot Assets protocol will commit the root hash of the Merkle tree to the BTC chain, but the content of the Merkle tree is stored in Tapd's database off-chain. This indicates that in order to achieve decentralization of Taproot Assets protocol, in addition to the private keys corresponding to the assets, users also need these off-chain proof data.&#x20;

BitTap wallet currently does not provide support for it. Our current solution is to address the issue of user private keys. In the future product upgrade, we will provide users with proof data downloads and imports for certain Taproot Assets, achieving true decentralization of Taproot Assets protocol.


# Get Started

Now ready to use BitTap wallet playing with Taproot Assets in a truly decentralized way!

{% embed url="<https://www.youtube.com/watch?v=UPl0_wrGpDQ>" %}
BitTap: The First Decentralized Wallet on Taproot Assets
{% endembed %}

## Create or Import  Wallet

First to create a new wallet, or import a wallet by mnemonic words.

<div align="left"><figure><img src="/files/ECtmNxGQ87mUMhOpSAHV" alt=""><figcaption></figcaption></figure></div>

## Receive & Send Assets

BitTap wallet enables users to receive or send btc and Taproot assets.

<figure><img src="/files/CMVoWTYq4E8z7HOgH1cB" alt=""><figcaption></figcaption></figure>

## Importing Taproot Assets

Users can import assets into BitTap wallet  from  other Taproot Assets universes.

> A Taproot Assets universe is a repository of assets and their proofs. A universe may serve information about a single or multiple asset types (e.g. a specific stablecoin or all stablecoins).


# Privacy Policy

**Last Updated:** 2024/10/25\
Welcome to BitTap Wallet (referred to as “we,” “our,” or “the Wallet”). We are committed to protecting your privacy and complying with relevant laws and regulations. This privacy policy outlines how we collect, use, store, and disclose your information. Please read it carefully

## **1. Information We Collect**

### **1.1 No Personal Identification Information**<br>

BitTap is a decentralized wallet. We do not require any personal identification information (such as name, ID number, or address) for you to use the core functions of the Wallet.

### **1.2 Automatically Collected Information**

\
While we do not collect personal identification information, we may automatically collect some data to improve our services and enhance user experience, such as:

* **Device Information**: Including device type, operating system, app version, etc.
* **Usage Data**: Information on how the Wallet is used, error reports, and crash logs.
* **Wallet Interaction Data**: Data related to interactions with the blockchain network (such as transaction records and wallet addresses). This is public blockchain data, not personally identifiable information.

### **1.3 Blockchain Data**

\
BitTap Wallet is a decentralized Bitcoin wallet, and all transactions and address information are recorded on the Bitcoin blockchain. Since blockchain data is public and transparent, it is accessible to anyone via blockchain explorers.

## **2. How We Use Your Information**

\
The information we collect may be used for the following purposes:

* **Improving User Experience**: To analyze user behavior and improve the functionality and interface of the product.
* **Troubleshooting and Security**: To monitor system performance and detect abnormal activities, ensuring the security of user assets.
* **Legal Compliance**: We may disclose certain information if required by law.

## **3. Information Storage and Security**

### **3.1 Information Storage**

\
We do not store your private keys, seed phrases, or any information that could give access to your assets. All relevant data is stored locally on your device, and you are solely responsible for managing and safeguarding this data.

### **3.2 Security Measures**

\
We take reasonable technical and administrative measures to protect your information from loss, misuse, or unauthorized access. However, please note that due to the nature of the internet, complete security cannot be guaranteed.

## **4. Third-Party Services**

\
BitTap Wallet may integrate with third-party services, such as blockchain explorers, node providers, or analytics tools. These third parties may collect, process, and store data related to your interactions on their platforms. We do not control the privacy practices of these third parties, and we encourage you to review their privacy policies.

## **5. Your Rights**

### **5.1 Anonymous Use**

\
You can use most of BitTap Wallet’s features without providing any personal identification information.

### **5.2 Data Access and Deletion**

\
Since we do not store personal identification information, there is no need to request access to or deletion of personal data. You have full control over your transaction data on the blockchain, which cannot be deleted or modified.

\
**5.3 Privacy Settings**

\
You can adjust certain features through the Wallet’s privacy settings (such as enabling or disabling analytics tools or connecting with third-party services) to further control data collection behavior.<br>

## **6. Children’s Privacy**

\
Our products are not intended for use by anyone under the age of 18. We do not knowingly collect information from minors. If we become aware that a minor has provided us with information, we will take steps to delete that information immediately.

## **7. Policy Updates**

\
We may update this Privacy Policy periodically. In the event of significant changes, we will notify you through announcements or other reasonable means. We encourage you to review this policy regularly to stay informed about our latest practices.<br>

## **8. Contact Us**

\
If you have any questions or suggestions regarding this Privacy Policy, please contact us at:

* Email: <Contact@bittap.org>

## **Effective Date**:&#x20;

This Privacy Policy is effective as of the date of publication.


# Overview

Welcome to the BitTap Decentralized MarketPlace for Taproot Assets.

## On the Road!


# Overview

Welcome to the developer documentation for BitTap Wallet.

## Architecture

Tapd is the official implementation of[ Taproot Assets Protocol](https://docs.lightning.engineering/the-lightning-network/taproot-assets/taproot-assets-protocol), but with an issue that end users must deploy an own Tapd and LND locally to master their wallet keys; otherwise, they have to escrow their wallet keys to the service provider who is running [Tapd](https://github.com/lightninglabs/taproot-assets) and [LND](https://github.com/lightningnetwork/lnd) locally.

BitTap solves this issue by introducing another layer, which Bittapd stands for. Bittapd is a service deployed on the Tapd side, working like an Taproot Assets Protocol's agent to help facilitate the interactions between Tapd and end users which have their self-custodial keys.

The architecture of BitTap Wallet shows below. End users aka. Browser Extension Wallet don't communicate with Tapd directly, instead they call Bittapd's API for everything except that they will  generate their own private/public keys for BTC and Taproot Assets.&#x20;

<figure><img src="/files/XExvF0y5uatBZ0PxTDSc" alt=""><figcaption><p>BitTap wallet architecture</p></figcaption></figure>

End users generate and manage the keys, and Bittapd don't need private keys to work. When private keys are needed to sign a transaction, Bittapd will ask for it to be conducted on the wallet side by the end user. In this way, BitTap wallet is a truly non-custodial wallet for Taproot Assets.

## API Resources

While BitTap team has developed the first non-custodial browser extension wallet for Taproot Assets in the world, we would like to open the capability to our partners to build truly decentralized web3 together so that in our partners' products, end users can truly own their Taproot Assets as well.&#x20;


# API Reference


# CreateWallet

Create a wallet for the end user.

<mark style="color:green;">`POST`</mark> /api/create-wallet

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name             | Type   | Description                                      |
| ---------------- | ------ | ------------------------------------------------ |
| `asset_pubkey`   | string | Account extended public key to derive asset keys |
| `account_pubkey` | string | Account extended public key to derive BTC keys   |

**Request**

```json
{
"asset_pubkey":"zpub6rCz8eKwNryyQifJK4yj7KEKzA5XDp31DGf6EpmBgdZnDjPajMVgRJMB8hzNLYmaufVRqXBWcKV5aeepJSY3uSF5z3yPB14jFPhi6Aq2Y2T",
"account_pubkey":"zpub6rU6HxpLkQUXeiHJTr43TW6uNaNZGvsrKT5YKiVBmwkKwvwTm5AXKTynsmUewP8TFRvccq6Z4EJ4L7q7ycc416fT8TGdoTYHn1BmSAuMkSJ"
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "wallet_id": "263afad1-a7a0-4af9-8ceb-5722aa0114fa",
  "address": "bc1qp9zm6x5q6y02036l2q93936c4fs3acjr546yly"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# NewAddr

Create a new Taproot Assets address.

<mark style="color:green;">`POST`</mark> /api/new-asset-address

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name        | Type   | Description                                  |
| ----------- | ------ | -------------------------------------------- |
| `wallet_id` | string | The end user's wallet id                     |
| `asset_id`  | string | The asset genesis ID of the asset to receive |
| amount      | uint64 | The amount of the asset to receive           |

**Request**

```json
{
  "wallet_id": "10e21d53-82d3-43d6-99bc-03ea6945d902",
  "asset_id": "75efd20fbe6bee21182c64d5c9954182f3d1fff9f815bfbb364e260b1b6b4113",
  "amount": 100
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": 0,
    "data": {
        "address": "taprt1qqqsqqspqqzzqa006g8mu6lwyyvzcex4ex25rqhn68lln7q4h7anvn3xpvdkksgnqcss9frv8vum00v28v3uveyg5j8snfqhzrx538pnpj5u33e7wtfp48mupqss9u4y9kpxl0du9che6gmq89hvgl5vy60wlu4pdnkz2t3sdpmcs7vrpgqkgrp0dpshx6rdv95kcw309akkz6tvvfhhstn5v4ex66twv9kzumrfva58gmnfdenjuar0v3shjw35xsespk6w0d"
    },
    "message": "",
    "traceid": "e74b1118-9bb1-4249-917f-ea29097dae78"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# DecodeAddr

Decode a Taproot Assets address.

<mark style="color:green;">`POST`</mark> /api/decode-addr

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name   | Type   | Description           |
| ------ | ------ | --------------------- |
| `addr` | string | The address to decode |

**Request**

```json
{
  "address": "taprt1qqqsqqspqqzzqa006g8mu6lwyyvzcex4ex25rqhn68lln7q4h7anvn3xpvdkksgnqcss9frv8vum00v28v3uveyg5j8snfqhzrx538pnpj5u33e7wtfp48mupqss9u4y9kpxl0du9che6gmq89hvgl5vy60wlu4pdnkz2t3sdpmcs7vrpgqkgrp0dpshx6rdv95kcw309akkz6tvvfhhstn5v4ex66twv9kzumrfva58gmnfdenjuar0v3shjw35xsespk6w0d"
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": 0,
    "data": {
        "encoded": "taprt1qqqsqqspqqzzqa006g8mu6lwyyvzcex4ex25rqhn68lln7q4h7anvn3xpvdkksgnqcss9frv8vum00v28v3uveyg5j8snfqhzrx538pnpj5u33e7wtfp48mupqss9u4y9kpxl0du9che6gmq89hvgl5vy60wlu4pdnkz2t3sdpmcs7vrpgqkgrp0dpshx6rdv95kcw309akkz6tvvfhhstn5v4ex66twv9kzumrfva58gmnfdenjuar0v3shjw35xsespk6w0d",
        "asset_id": "de/SD75r7iEYLGTVyZVBgvPR//n4Fb+7Nk4mCxtrQRM=",
        "amount": 100,
        "script_key": "AqRsOzm3vYo7I8ZkiKSPCaQXEM1InDMMqcjHPnLSGp98",
        "internal_key": "AvKkLYJvvbwuL50jYDluxH6MJp7v8qFs7CUuMGh3iHmD",
        "taproot_output_key": "TyDMvV/OqBVV+VSdS6XB8PYNgCihmAYO8lQX9MrLR/4=",
        "proof_courier_addr": "hashmail://mailbox.terminal.lightning.today:443"
    },
    "message": "",
    "traceid": "6cd94418-2871-464d-b4de-5e3d14195f07"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Some of the response fields are encoded as base64 since the type of fields is \[]byte, which should be decoded to hex string before usage.
{% endhint %}

{% hint style="info" %}
If a field is empty it will not show in the response message, e.g. the 'group\_key' in the above.
{% endhint %}


# QueryAddrs

Query all created Taproot Assets addresses in a wallet.

<mark style="color:green;">`POST`</mark> /api/query-addrs

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name        | Type   | Required | Description              |
| ----------- | ------ | -------- | ------------------------ |
| `wallet_id` | string | true     | The end user's wallet id |
| page\_num   | int    | false    | for paging, default 1    |
| page\_size  | int    | false    | for paging, default 10   |

**Request**

```json
{
  "wallet_id": "10e21d53-82d3-43d6-99bc-03ea6945d902",
  "page_num": 1,
  "page_size": 10
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": 0,
    "data": {
        "addrs": [
            {
                "encoded": "taprt1qqqsqqspqqzzpghdayflqgqyxwpvjl2lrtkz4grl7x7ulyecta3q33sx2r0fmv66qcss9q4sd6fp6xakequg3lglmq3wwgvk3gurf2rn84k2amktauxlejdupqssxm3aw02xv45tf8gue5xxgwmd2xjamwsjw6527ryckqg6cpkczy6lpgqusrp0dpshx6rdv95kcw309akkz6tvvfhhstn5v4ex66twv9kzumrfva58gmnfdenjuar0v3shjw35xsesnhlwrv",
                "asset_id": "ou3pE/AgBDOCyX1fGuwqoH/xvc+TOF9iCMYGUN6ds1o=",
                "asset_type": "NORMAL",
                "amount": 200,
                "group_key": null,
                "script_key": "AoKwbpIdG7bIOIj9H9gi5yGWijg0qHM9bK7uy+8N/Mm8",
                "internal_key": "A249c9RmVotJ0czQxkO21Rpd26EnaorwyYsBGsBtgRNf",
                "tapscript_sibling": null,
                "taproot_output_key": "5rAtRHYEsAw8QxMiqEadRd+/KGHLkzM3AgVlOo1ft1I=",
                "proof_courier_addr": "hashmail://mailbox.terminal.lightning.today:443",
                "asset_version": "ASSET_VERSION_V0"
            },
            {
                "encoded": "taprt1qqqsqqspqqzzpghdayflqgqyxwpvjl2lrtkz4grl7x7ulyecta3q33sx2r0fmv66qcssyvdn8h4das523j3066xewx5jxwpm4rzenvjy3h0l94upr56ruaprpqss9dej7u0fgll8yjs8pxzd4h6kp95nxsh66283z2l0n9nzhafefld6pgpl6qfvpshksctndpkkz6tv8ghj7mtpd9kxymmc9e6x2undd9hxzmpwd35kw6r5de5kueeww3hkgcte8g6rgvcuupn0m",
                "asset_id": "ou3pE/AgBDOCyX1fGuwqoH/xvc+TOF9iCMYGUN6ds1o=",
                "asset_type": "NORMAL",
                "amount": 300,
                "group_key": null,
                "script_key": "AjGzPerewoqMov1o2XGpIzg7qMWZskSN3/LXgR00PnQj",
                "internal_key": "Arcy9x6Uf+ckoHCYTa31YJaTNC+tKPESvvmWYr9TlP26",
                "tapscript_sibling": null,
                "taproot_output_key": "6VqagMVX988EoIZf0jl7kBvvOqIgCL+okJyifSUUTm8=",
                "proof_courier_addr": "hashmail://mailbox.terminal.lightning.today:443",
                "asset_version": "ASSET_VERSION_V0"
            }
        ]
    },
    "message": "",
    "traceid": "4dd6a268-81dd-47f0-a0db-68dc8fc97701"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# ImportAsset

Import a Taproot Asset from other universe.

<mark style="color:green;">`POST`</mark> /api/import-asset

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name            | Type   | Description                                       |
| --------------- | ------ | ------------------------------------------------- |
| `universe_host` | string | The host:port or just host of the remote universe |
| asset\_id       | string | The asset ID to import from  the universe         |

**Request**

```json
{
    "universe_host": "universe.lightning.finance:10029",
    "asset_id":"75efd20fbe6bee21182c64d5c9954182f3d1fff9f815bfbb364e260b1b6b4113"
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": 0,
    "data": {
        "asset_id": "75efd20fbe6bee21182c64d5c9954182f3d1fff9f815bfbb364e260b1b6b4113",
        "name": "bits",
        "asset_type": "NORMAL",
        "total_supply": 100000000,
        "genesis_point": "74990e35efe603b89adb1afbb703b240e296c76650033fe7e401fc42863af6e4:1"
    },
    "message": "",
    "traceid": "6cd94418-2871-464d-b4de-5e3d14195f07"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# QueryAssetStat

Query all Taproot Assets metadata in Bittapd without regarding end users.

<mark style="color:green;">`POST`</mark> /api/query-asset-stats

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Request Body**

| Name        | Type   | Required | Desc                   |
| ----------- | ------ | -------- | ---------------------- |
| page\_num   | uint   | false    | page\_num, default 1   |
| page\_size  | uint   | false    | page\_size, default 10 |
| asset\_name | string | false    | default empty          |
| asset\_id   | string | false    | asset\_id(in hex form) |

{% hint style="info" %}
Without any input needed
{% endhint %}

**Request Demo**

```json
{
    "page_num": 1,
    "page_size": 10,
    "asset_name": "xxx"
}
```

**Response Demo**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": 0,
    "data": {
        "asset_stats": [
            {
                "asset": {
                    "asset_id": "ou3pE/AgBDOCyX1fGuwqoH/xvc+TOF9iCMYGUN6ds1o=",
                    "genesis_point": "8b6ba4532de33ca1726791715e21e6a10a9b51ac254032200c8d03f4577907c5:0",
                    "total_supply": 10000,
                    "asset_name": "bits",
                    "genesis_height": 154,
                    "genesis_timestamp": 1718353794,
                    "anchor_point": "fc2b6b3a8e2788f48350f289d56ea4b20c148804209e643e8855522da0498062:0"
                },
                "total_proofs": 1
            },
            {
                "asset": {
                    "asset_id": "de/SD75r7iEYLGTVyZVBgvPR//n4Fb+7Nk4mCxtrQRM=",
                    "genesis_point": "cedeca49024aea0bb4341607b855de1a07f6fb9ecf2b4969ce130869a377fabd:1",
                    "total_supply": 1000000,
                    "asset_name": "gold",
                    "genesis_height": 2811,
                    "genesis_timestamp": 1719114639,
                    "anchor_point": "0b54e95197b4b9d16c1fd0b1bddb68e060e99cf61a34dcb580f86c3d885b9b93:0"
                },
                "total_proofs": 1
            },
            {
                "asset": {
                    "asset_id": "EXFAh5hkLtDsG2Q1tkwyrsOaLEbzCjVoHY5opOoaLsI=",
                    "genesis_point": "6344435b2681317ff01ecf421854b85556c1619bfadde08441f10a09f46d6d48:1",
                    "total_supply": 1000000,
                    "asset_name": "taps",
                    "genesis_height": 2805,
                    "genesis_timestamp": 1719107411,
                    "anchor_point": "cedeca49024aea0bb4341607b855de1a07f6fb9ecf2b4969ce130869a377fabd:0"
                },
                "total_proofs": 1
            }
        ]
    },
    "message": "",
    "traceid": "4975e052-faf2-484d-87be-94dca36df7bc"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# ListAssetHistory

List all Taproot Assets and BTC transaction history in a wallet.

<mark style="color:green;">`POST`</mark> /api/list-asset-history

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `token`            |

#### Request Body

| Name            | Type   | Required | Description                                                                                                      |
| --------------- | ------ | -------- | ---------------------------------------------------------------------------------------------------------------- |
| wallet\_id      | string | true     | The end user's wallet id                                                                                         |
| occurred\_after | int64  | false    | Occurred after this Unix timestamp                                                                               |
| asset\_id       | string | false    | asset id(hex form) for TAP assets, (for btc assets the asset\_id is btc). If empty, all assets shall be returned |

#### Response Body

| Name     | Type   | Description                                             |
| -------- | ------ | ------------------------------------------------------- |
| op\_type | string | 0 out; 1 in                                             |
| pending  | bool   | false; true (indicating if the tx is included in block) |

#### Request Demo

```json
{
  "wallet_id": "10e21d53-82d3-43d6-99bc-03ea6945d902",
  "occurred_after":0
}
```

**Response Demo**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": 0,
    "data": {
        "tx_histories": [
            {
                "timestamp": 1721854538,
                "tx_id": "b4e0d6a6fcb251378fd356504bede98ef769d7450e83b8be8333e98bc59014b8",
                "asset_id": "4ea437a417d3fe8bd735dacd3ad36bd6758dabcb7080f7528299d5a30e44e328",
                "amount": 100,
                "op_type": "0"
            },
            {
                "timestamp": 1721825649,
                "tx_id": "ca6197ee1302c0d483856e14337ece9373b3ec148adc6ec4f8aaf2c550a3b90f",
                "asset_id": "4ea437a417d3fe8bd735dacd3ad36bd6758dabcb7080f7528299d5a30e44e328",
                "amount": 700,
                "op_type": "1"
            },
            {
                "timestamp": 1721825438,
                "tx_id": "c95e629444449451582089c64e835316410dc9cd5539e2f44092a600b48c6f8a",
                "asset_id": "4ea437a417d3fe8bd735dacd3ad36bd6758dabcb7080f7528299d5a30e44e328",
                "amount": 800,
                "op_type": "1"
            },
            {
                "timestamp": 1721824876,
                "tx_id": "370fac49786be313f6bbe78aa7744c24bda911d3e6a71db8538afbcea5d9a9d2",
                "asset_id": "4ea437a417d3fe8bd735dacd3ad36bd6758dabcb7080f7528299d5a30e44e328",
                "amount": 3000,
                "op_type": "1"
            }
        ]
    },
    "message": "",
    "traceid": "98539813-a3f4-4846-a716-862c19ecf1fa"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# Estimate-tx-fee

Estimate the transaction fee for current layer 1 or layer 2 asset transfer.

<mark style="color:green;">`POST`</mark> /api/estimate-tx-fee

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `token`            |

#### Request Body

| Name       | Type   | Required | Description                                                |
| ---------- | ------ | -------- | ---------------------------------------------------------- |
| wallet\_id | string | true     | The end user's wallet id                                   |
| amount     | int    | false    | the amount of satoshi to send in case of type 1            |
| type       | int    | true     | 1  layer 1 btc transfer;  2 layer 2 taproot asset transfer |
| fee\_rate  | int    | true     | satoshi cost per byte                                      |

#### Response Body

| Name    | Type | Description                            |
| ------- | ---- | -------------------------------------- |
| tx\_fee | int  | estimated tx\_fee for this transaction |

#### Request Demo

```json
{
  "wallet_id": "10e21d53-82d3-43d6-99bc-03ea6945d902",
  "type": 1,
  "amount": 20000,
  "fee_rate": 21
}
```

**Response Demo**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": 0,
    "data": {
        "tx_fee": 1512
    },
    "message": "",
    "traceid": "e8857f31-91ee-47ea-975c-d05f6328d9fb"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# GetAssetBalance

Get all Taproot Assets balance in a wallet.

<mark style="color:green;">`POST`</mark> /api/get-asset-balance

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name        | Type   | Description              |
| ----------- | ------ | ------------------------ |
| `wallet_id` | string | The end user's wallet id |

**Request**

```json
{
  "wallet_id": "10e21d53-82d3-43d6-99bc-03ea6945d902"
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": 0,
    "data": {
        "assets_balance": [
            {
                "asset_id": "ou3pE/AgBDOCyX1fGuwqoH/xvc+TOF9iCMYGUN6ds1o=",
                "asset_tag": "bits",
                "amount": 271,
                "type": 0
            }
        ]
    },
    "message": "",
    "traceid": "48e2e725-adcb-4333-a587-5aa9e4b0c403"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
In the above outputs, "type" has two values: 0 for Normal, 1 for Collectible&#x20;
{% endhint %}


# GetBtcBalance

Get BTC balance in a wallet.

<mark style="color:green;">`POST`</mark> /api/get-btc-balance

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name        | Type   | Description                                                |
| ----------- | ------ | ---------------------------------------------------------- |
| `wallet_id` | string | The end user's wallet id                                   |
| btc\_addr   | string | The returned BTC address when initially create this wallet |

**Request**

```json
{
  "wallet_id": "10e21d53-82d3-43d6-99bc-03ea6945d902",
  "btc_addr": "bc1qp9zm6x5q6y02036l2q93936c4fs3acjr546yly"
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": 0,
    "data": {
        "addr": "bc1qp9zm6x5q6y02036l2q93936c4fs3acjr546yly",
        "balance": 169931100
    },
    "message": "",
    "traceid": "a73c5849-6a10-4bda-a411-d6c236277939"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# SendAsset

Sending assets requires several rounds of communication between wallet and bittapd, because bittapd needs end users to sign twice.

<details>

<summary>Step1: TransferAsset</summary>

Wallet calls this to transfer an asset to a specific Taproot Assets address. Virtual psbts are returned for the end user's first sign.&#x20;

</details>

<details>

<summary>Step 2: AnchorVirtualPsbt</summary>

Continuingly from Step1, the end user signs the virtual psbts locally, to provide witnesses for Taproot Assets spend. Wallet should NOT finalize or extract that transaction. Then make this call to  send the signed virtual psbts back.&#x20;

Bittapd will verify the signatures to make sure it meets the spending conditions of Taproot Assets Protocol. Then Bittapd will make anchored psbt to anchor this transfer to BTC. The result is another psbt to be returned for the end user's second sign.&#x20;

</details>

<details>

<summary>Step 3: PublishTransfer</summary>

The end user will sign the psbt returned from Step 2, and before call this to broadcast to BTC blockchain, the signed psbt needs to be finalized. In the end, if the transaction get confirmed, that means the Taproot Assets transfer successfully. The receiver will find the new asset on chain, and verify the proof which sender made to it.

</details>


# TransferAsset

First step to transfer Taproot Assets to an address. Virtual psbts for active assets and passive assets will be returned in response for user's first time sign.

<mark style="color:green;">`POST`</mark> /api/transfer-asset

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name        | Type   | Description                                   |
| ----------- | ------ | --------------------------------------------- |
| `wallet_id` | string | The end user's wallet id                      |
| address     | string | Taproot Assets address to send this asset to. |

**Request**

```json
{
  "wallet_id": "10e21d53-82d3-43d6-99bc-03ea6945d902",
  "address": "taprt1qqqsqqspqqzzpghdayflqgqyxwpvjl2lrtkz4grl7x7ulyecta3q33sx2r0fmv66qcss98xpemg90uqrndczdd064zazuuhchlk4tvyc3mpq6t4yqncqdht8pqssxv0q4z33mrqgg3dj5unq7fsn835ta3rwfgnx9ws28tu06mk6p38fpgqkkrp0dpshx6rdv95kcw309akkz6tvvfhhstn5v4ex66twv9kzumrfva58gmnfdenjuar0v3shjw35xses3afl9n"  
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": 0,
    "data": {
"virtual_psbts": ["70736274ff01005e0200000001fdb5daf62ea60fbdd7e8a5a8d6fa323e4b56004f6df5ef5c966ad919e32b747c000000000000000000012c01000000000000225120b49e7bff6e54a383c71e63e77adcc46436e63387a981bfb57106cfd91df2cbf7000000000001012b2c0100000000000022512031b33deadec28a8ca2fd68d971a923383ba8c599b2448ddff2d7811d343e7423220603e5a37878f6a05963fcfc4f2640a513aabe564aa033af397b2279ce168e928bf21800000000f903008001000080d4000080000000000a0000002116e5a37878f6a05963fcfc4f2640a513aabe564aa033af397b2279ce168e928bf2190000000000f903008001000080d4000080000000000a000000011720e5a37878f6a05963fcfc4f2640a513aabe564aa033af397b2279ce168e928bf20000"],
"passive_asset_psbts":[]
    },
    "message": "",
    "traceid": "a73c5849-6a10-4bda-a411-d6c236277939"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# AnchorVirtualPsbt

Second step to transfer Taproot Assets to an address. This will accept the user's signed virtual psbt to verify, and if valid, return anchored psbt for another signature.

<mark style="color:green;">`POST`</mark> /api/anchor-virtual-psbt

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name                  | Type       | Description                             |
| --------------------- | ---------- | --------------------------------------- |
| `wallet_id`           | string     | The end user's wallet id                |
| fee\_rate             | int64      | Fee rate in sat/vB                      |
| asset\_psbts          | \[]\[]byte | Signed virtual psbts for active assets  |
| passive\_asset\_psbts | \[]\[]byte | Signed virtual psbts for passive assets |

{% hint style="warning" %}
As request data, signed psbt should NOT be finalized by wallet.
{% endhint %}

**Request**

```json
{
    "wallet_id":"23a06ee3-050a-46f7-9eec-68d95471dd6c",
    "fee_rate":5,
    "asset_psbts": ["cHNidP8BAF4CAAAAAf212vYupg+91+ilqNb6Mj5LVgBPbfXvXJZq2RnjK3R8AAAAAAAAAAAAASwBAAAAAAAAIlEgtJ57/25Uo4PHHmPnetzEZDbmM4epgb+1cQbP2R3yy/cAAAAAAAEBKywBAAAAAAAAIlEgMbM96t7Cioyi/WjZcakjODuoxZmyRI3f8teBHTQ+dCMiBgPlo3h49qBZY/z8TyZApROqvlZKoDOvOXsiec4WjpKL8hgAAAAA+QMAgAEAAIDUAACAAAAAAAoAAAABE0BUrwjMP3/NBckGcn45fZN2jgpESRFOBEPGlLsS4ZChIYJcXBsd44NWMpr+1jzNJLg/aioYSOMusgpCmL8aEb0xIRblo3h49qBZY/z8TyZApROqvlZKoDOvOXsiec4WjpKL8hkAAAAAAPkDAIABAACA1AAAgAAAAAAKAAAAARcg5aN4ePagWWP8/E8mQKUTqr5WSqAzrzl7InnOFo6Si/IAAA=="],
    "passive_asset_psbts":[]
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": 0,
    "data": {
         "anchor_psbt": ["70736274ff0100d102000000028ba9299f260123601423ce71437928ee313bf44b816b35c5aa07c0e59396cdfc0100000000ffffffffaca2a9b5161a7bd01df1b4a5572fc7a2fe8ccfddfcae13d54f2b1aa5f0a9521f01000000000000000003e80300000000000022512056b5abe9450b4ccafeda69d82491f13299e0b6b7c25a113f80dd5b030377e9b0e803000000000000225120cd586be63ca9c2d4da65fc295ddb415a1ecc04b7cbe46aa546b0485ce2b25fed5cf1200a000000001600140b42e943f0c6eb2674576f867331bd09a590b4bd00000000000100de02000000000101918f623588b64c3488e2cfa1a9d849b630fa26e69cea9b9da8b1fac36c6c89aa0100000000ffffffff02002d3101000000001600142b6bb0717085d23e76a3e5cb55e77d3c3dcc0f9ee026210a000000001600140b42e943f0c6eb2674576f867331bd09a590b4bd02473044022007ef8f83c01397e1e37a58b362d92e3d19185e0df96fedb870c81925ed47d1c002201dc580bcac5f29fba69dad90c538d8178e388cf4352aff6de1dbb4be98aa12420121032881e7339571ee8de34b00dbcc10f423d70dd5d6cc51c7d6ecf33255311d04e00000000001011fe026210a000000001600140b42e943f0c6eb2674576f867331bd09a590b4bd010304010000002206032881e7339571ee8de34b00dbcc10f423d70dd5d6cc51c7d6ecf33255311d04e0180000000054000080000000800000008000000000000000000001012be803000000000000225120e95a9a80c557f7cf04a0865fd2397b901bef3aa22008bfa8909ca27d25144e6f220602b732f71e947fe724a070984dadf5609693342fad28f112bef99662bf5394fdba1800000000f903008001000080d4000080000000000b0000002116b732f71e947fe724a070984dadf5609693342fad28f112bef99662bf5394fdba190000000000f903008001000080d4000080000000000b000000011720b732f71e947fe724a070984dadf5609693342fad28f112bef99662bf5394fdba011820eaa073d2073c9688b5cd5b549396a542497fb48fa7ccf8430c9124511334332500220203001a739403bcabcd3d00b02d84666be9c1d1063ea3d0588ec124cb8955c09b871800000000f903008001000080d4000080000000000d000000010520001a739403bcabcd3d00b02d84666be9c1d1063ea3d0588ec124cb8955c09b872107001a739403bcabcd3d00b02d84666be9c1d1063ea3d0588ec124cb8955c09b87190000000000f903008001000080d4000080000000000d000000017020ead1cbf1c74e7d3a236c1464e6e448dc82a69142f1f9c26f68b6a571472ee8fe017120ead1cbf1c74e7d3a236c1464e6e448dc82a69142f1f9c26f68b6a571472ee8fe0001052031e0a8a31d8c08445b2a7260f26133c68bec46e4a2662ba0a3af8fd6eda0c4e9017020d1c5c94fe98796690caf15f6ebdb793eddc2b2eab360046b483539c0810b2481017120d1c5c94fe98796690caf15f6ebdb793eddc2b2eab360046b483539c0810b2481002202035c0ed3efc7edee23727c1f39b92d0910ea65d11c67384673048eea8dc3b04e971800000000540000800000008000000080010000000700000000"]
    },
    "message": "",
    "traceid": "a73c5849-6a10-4bda-a411-d6c236277939"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# PublishTransfer

Third step to transfer Taproot Assets to an address. This will accept the user's signed anchor psbt to broadcast to BTC network, if confirmed send proof to receiver too.

<mark style="color:green;">`POST`</mark> /api/publish-transfer

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name         | Type    | Description                            |
| ------------ | ------- | -------------------------------------- |
| `wallet_id`  | string  | The end user's wallet id               |
| anchor\_psbt | \[]byte | Signed anchored psbt for this transfer |

{% hint style="warning" %}
As request data, signed psbt MUST be finalized but NOT extracted by wallet.
{% endhint %}

**Request**

```json
{
    "wallet_id":"23a06ee3-050a-46f7-9eec-68d95471dd6c",
    "anchor_psbt": "cHNidP8BANECAAAAAoupKZ8mASNgFCPOcUN5KO4xO/RLgWs1xaoHwOWTls38AQAAAAD/////rKKptRYae9Ad8bSlVy/Hov6Mz938rhPVTysapfCpUh8BAAAAAAAAAAAD6AMAAAAAAAAiUSBWtavpRQtMyv7aadgkkfEymeC2t8JaET+A3VsDA3fpsOgDAAAAAAAAIlEgzVhr5jypwtTaZfwpXdtBWh7MBLfL5GqlRrBIXOKyX+1c8SAKAAAAABYAFAtC6UPwxusmdFdvhnMxvQmlkLS9AAAAAAABAN4CAAAAAAEBkY9iNYi2TDSI4s+hqdhJtjD6Juac6pudqLH6w2xsiaoBAAAAAP////8CAC0xAQAAAAAWABQra7BxcIXSPnaj5ctV5308PcwPnuAmIQoAAAAAFgAUC0LpQ/DG6yZ0V2+GczG9CaWQtL0CRzBEAiAH74+DwBOX4eN6WLNi2S49GRheDflv7bhwyBkl7UfRwAIgHcWAvKxfKfumna2QxTjYF444jPQ1Kv9t4du0vpiqEkIBIQMogeczlXHujeNLANvMEPQj1w3V1sxRx9bs8zJVMR0E4AAAAAABAR/gJiEKAAAAABYAFAtC6UPwxusmdFdvhnMxvQmlkLS9AQhrAkcwRAIgVQh4C0yCoBVmdXlB94fGroKEr7jE6nj2W/8B7zf3dqECIAwNbCJF+SIJJHoPGGdJRKCXJQo7CximmrS4r7c3OYzMASEDKIHnM5Vx7o3jSwDbzBD0I9cN1dbMUcfW7PMyVTEdBOAAAQEr6AMAAAAAAAAiUSDpWpqAxVf3zwSghl/SOXuQG+86oiAIv6iQnKJ9JRRObwEIQgFAhgldmxXaZ5cGfShER+T20PJrRCwwTCJoH0NUZDkm36SEswaoRqowwqDrKkk+Y9K9PObB+YyZ5wsvE9ms89KLhAAiAgMAGnOUA7yrzT0AsC2EZmvpwdEGPqPQWI7BJMuJVcCbhxgAAAAA+QMAgAEAAIDUAACAAAAAAA0AAAABBSAAGnOUA7yrzT0AsC2EZmvpwdEGPqPQWI7BJMuJVcCbhyEHABpzlAO8q809ALAthGZr6cHRBj6j0FiOwSTLiVXAm4cZAAAAAAD5AwCAAQAAgNQAAIAAAAAADQAAAAFwIOrRy/HHTn06I2wUZObkSNyCppFC8fnCb2i2pXFHLuj+AXEg6tHL8cdOfTojbBRk5uRI3IKmkULx+cJvaLalcUcu6P4AAQUgMeCoox2MCERbKnJg8mEzxovsRuSiZiugo6+P1u2gxOkBcCDRxclP6YeWaQyvFfbr23k+3cKy6rNgBGtINTnAgQskgQFxINHFyU/ph5ZpDK8V9uvbeT7dwrLqs2AEa0g1OcCBCySBACICA1wO0+/H7e4jcnwfObktCRDqZdEcZzhGcwSO6o3DsE6XGAAAAABUAACAAAAAgAAAAIABAAAABwAAAAA="
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": 0,
    "data": {
        "transfer": {
            "transfer_timestamp": 1719383337,
            "anchor_tx_hash": "yYPyIWC9Cbx0zqYW8E9jC6hVpr5LkeYg0CkVXc6oc1s=",
            "anchor_tx_height_hint": 3011,
            "anchor_tx_chain_fees": 12700,
            "inputs": [
                {
                    "anchor_point": "1ecf413f05bbcd5b937203a433bc3909cb34198047720466f477dfc28f0757be:1",
                    "asset_id": "RJfR7toUx7i1ABTCZx5kMdsRFoj8ZqhSTsBTI0c6UD4=",
                    "script_key": "AoKwbpIdG7bIOIj9H9gi5yGWijg0qHM9bK7uy+8N/Mm8",
                    "amount": 200
                }
            ],
            "outputs": [
                {
                    "anchor": {
                        "outpoint": "5b73a8ce5d1529d020e6914bbea655a80b634ff016a6ce74bc09bd6021f283c9:0",
                        "value": 1000,
                        "internal_key": "A1VrOtSIbPIaLD9MKy0qcKysWDYqxLWsRVqcTQAxvojb",
                        "taproot_asset_root": "p61FvX9FJh/iYALmjatDSRrZ1dfDnhehaK5Nn9S2v8Q=",
                        "merkle_root": "p61FvX9FJh/iYALmjatDSRrZ1dfDnhehaK5Nn9S2v8Q="
                    },
                    "script_key": "AtOQA1M9zcR8UoD1fkB1A+puxrXBHK0nhKPUM8mOOrVn",
                    "amount": 134,
                    "new_proof_blob": "VEFQUAAEAAAAAAIkvlcHj8Lfd/RmBHJHgBk0ywk5vDOkA3KTW827BT9Bzx4AAAABBFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJbogAAAAAAAAAAAb9AYACAAAAAAECAdbio2Tb/kNDHNjwIeCdCGdAV+ovHJqyx7WLLh5R2KEBAAAAAP////++VwePwt939GYEckeAGTTLCTm8M6QDcpNbzbsFP0HPHgEAAAAAAAAAAAPoAwAAAAAAACJRIFT3AqOYTBcDCACOYaStX1hqwPeXVKhCS0FdA6Jgg2v86AMAAAAAAAAiUSAoDZhnVXqSsL6BTTHDZljZ3KFIG+n8ZQF3s7qczDQ65vJDugoAAAAAFgAUC0LpQ/DG6yZ0V2+GczG9CaWQtL0CRzBEAiAjx6YgiHOwQ+MAmWLI3YcFWtgVHc9oO+cdfxY3kyFNSAIgUmRjzAtrmOsVA7UmWd9ys2uU6A2TJ+pZrYhVuerKbyMBIQMogeczlXHujeNLANvMEPQj1w3V1sxRx9bs8zJVMR0E4AFA5K7kJxq+5vHr/+MxZ3nVLUmnb9nJWiXmoZFwTHXLOQpP0RVjTKHdCwl2Rt1xt7Hzcu65zo0BKRWsqNNu751JrwAAAAAIAQAK/QFZAAEAAk7VkuHNLOMocr2fIComrlImUP8ji1pqPCHZMaxvygr/CQAAAAAEYml0cz7KRh96hCoh8Sn12ezt363XPHJ4ghiXgTugCkdF9wsNAAAAAAAEAQAGAYYLrQGrAWW+VwePwt939GYEckeAGTTLCTm8M6QDcpNbzbsFP0HPHgAAAAFEl9Hu2hTHuLUAFMJnHmQx2xEWiPxmqFJOwFMjRzpQPgKCsG6SHRu2yDiI/R/YIuchloo4NKhzPWyu7svvDfzJvANCAUBvbvXhDRBaWDcULhunwjHV3P21R/b8+W1sT2l9w0ovoZdb/jnleUplMlVADmO/EF4+ycyTCp/Vm+qcnFcHtjXLDSi9qU4ijBm5gff2c1HaVqJmu8rmVWbJfrvaX1/+MQIR4wAAAAAAAADIDgIAABAhAtOQA1M9zcR8UoD1fkB1A+puxrXBHK0nhKPUM8mOOrVnDJ8ABAAAAAACIQNVazrUiGzyGiw/TCstKnCsrFg2KsS1rEVanE0AMb6I2wN0AUkAAQACIESX0e7aFMe4tQAUwmceZDHbERaI/GaoUk7AUyNHOlA+BCIAAP//////////////////////////////////////////AicAAQACIgAA//////////////////////////////////////////8NyQHHAAQAAAABAiECDLezfjmhFA7PaDUm6qwG3hqTIODkav9OYm1XOANslSwDnAFxAAEAAiBEl9Hu2hTHuLUAFMJnHmQx2xEWiPxmqFJOwFMjRzpQPgRKAAGSDA6qqq2+tmrkN6RIwc4YSuFU7BmFEBmxSVSGaI37qQAAAAAAAABC/////////////////////////////////////////98CJwABAAIiAAD//////////////////////////////////////////xYEAAAAAA==",
                    "split_commit_root_hash": "valOIowZuYH39nNR2laiZrvK5lVmyX672l9f/jECEeM=",
                    "output_type": 1
                },
                {
                    "anchor": {
                        "outpoint": "5b73a8ce5d1529d020e6914bbea655a80b634ff016a6ce74bc09bd6021f283c9:1",
                        "value": 1000,
                        "internal_key": "Agy3s345oRQOz2g1JuqsBt4akyDg5Gr/TmJtVzgDbJUs",
                        "taproot_asset_root": "ZgxZUFedlHfaLIznIjSUMv14U0zsT6s+C0Fm/MyTgmM=",
                        "merkle_root": "ZgxZUFedlHfaLIznIjSUMv14U0zsT6s+C0Fm/MyTgmM="
                    },
                    "script_key": "AgS5Wabfeoa3uVSuJjuN6EBFC6b0S7xxzlKfhoB6NTBF",
                    "amount": 66,
                    "new_proof_blob": "VEFQUAAEAAAAAAIkvlcHj8Lfd/RmBHJHgBk0ywk5vDOkA3KTW827BT9Bzx4AAAABBFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJbogAAAAAAAAAAAb9AYACAAAAAAECAdbio2Tb/kNDHNjwIeCdCGdAV+ovHJqyx7WLLh5R2KEBAAAAAP////++VwePwt939GYEckeAGTTLCTm8M6QDcpNbzbsFP0HPHgEAAAAAAAAAAAPoAwAAAAAAACJRIFT3AqOYTBcDCACOYaStX1hqwPeXVKhCS0FdA6Jgg2v86AMAAAAAAAAiUSAoDZhnVXqSsL6BTTHDZljZ3KFIG+n8ZQF3s7qczDQ65vJDugoAAAAAFgAUC0LpQ/DG6yZ0V2+GczG9CaWQtL0CRzBEAiAjx6YgiHOwQ+MAmWLI3YcFWtgVHc9oO+cdfxY3kyFNSAIgUmRjzAtrmOsVA7UmWd9ys2uU6A2TJ+pZrYhVuerKbyMBIQMogeczlXHujeNLANvMEPQj1w3V1sxRx9bs8zJVMR0E4AFA5K7kJxq+5vHr/+MxZ3nVLUmnb9nJWiXmoZFwTHXLOQpP0RVjTKHdCwl2Rt1xt7Hzcu65zo0BKRWsqNNu751JrwAAAAAIAQAK/QKaAAEAAk7VkuHNLOMocr2fIComrlImUP8ji1pqPCHZMaxvygr/CQAAAAAEYml0cz7KRh96hCoh8Sn12ezt363XPHJ4ghiXgTugCkdF9wsNAAAAAAAEAQAGAUIL/QIWAf0CEgFlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF/QGnSgAB7tIRiaEdoIkzz5qOS8ypGLbtn9lVRjVKHnhNYpGwREEAAAAAAAAAhv////////////////////////////////////////9//QFZAAEAAk7VkuHNLOMocr2fIComrlImUP8ji1pqPCHZMaxvygr/CQAAAAAEYml0cz7KRh96hCoh8Sn12ezt363XPHJ4ghiXgTugCkdF9wsNAAAAAAAEAQAGAYYLrQGrAWW+VwePwt939GYEckeAGTTLCTm8M6QDcpNbzbsFP0HPHgAAAAFEl9Hu2hTHuLUAFMJnHmQx2xEWiPxmqFJOwFMjRzpQPgKCsG6SHRu2yDiI/R/YIuchloo4NKhzPWyu7svvDfzJvANCAUBvbvXhDRBaWDcULhunwjHV3P21R/b8+W1sT2l9w0ovoZdb/jnleUplMlVADmO/EF4+ycyTCp/Vm+qcnFcHtjXLDSi9qU4ijBm5gff2c1HaVqJmu8rmVWbJfrvaX1/+MQIR4wAAAAAAAADIDgIAABAhAtOQA1M9zcR8UoD1fkB1A+puxrXBHK0nhKPUM8mOOrVnDgIAABAhAgS5Wabfeoa3uVSuJjuN6EBFC6b0S7xxzlKfhoB6NTBFDJ8ABAAAAAECIQIMt7N+OaEUDs9oNSbqrAbeGpMg4ORq/05ibVc4A2yVLAN0AUkAAQACIESX0e7aFMe4tQAUwmceZDHbERaI/GaoUk7AUyNHOlA+BCIAAP//////////////////////////////////////////AicAAQACIgAA//////////////////////////////////////////8NyQHHAAQAAAAAAiEDVWs61Ihs8hosP0wrLSpwrKxYNirEtaxFWpxNADG+iNsDnAFxAAEAAiBEl9Hu2hTHuLUAFMJnHmQx2xEWiPxmqFJOwFMjRzpQPgRKAAF26KoRoRGyBKzu/UNvPHBDHyBefFiQTp9wenbbNHeQmAAAAAAAAACG/////////////////////////////////////////98CJwABAAIiAAD//////////////////////////////////////////w+fAAQAAAAAAiEDVWs61Ihs8hosP0wrLSpwrKxYNirEtaxFWpxNADG+iNsDdAFJAAEAAiBEl9Hu2hTHuLUAFMJnHmQx2xEWiPxmqFJOwFMjRzpQPgQiAAD//////////////////////////////////////////wInAAEAAiIAAP//////////////////////////////////////////FgQAAAAA"
                }
            ]
        }
    },
    "message": "",
    "traceid": "4315b0b1-7d26-4814-b2d8-b78e30705535"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# SendBtc

Sending BTC requires 2 rounds of communication between wallet and bittapd, because bittapd needs end users to sign only once.

<details>

<summary>Step1: TransferBtc</summary>

Wallet calls this to transfer BTC to a specific address. Psbt is returned for the end user's sign.&#x20;

</details>

<details>

<summary>Step 2: PublishTransferBtc</summary>

The end user will sign the psbt returned from Step 1, and before call this to broadcast to BTC blockchain, the signed psbt needs to be finalized and extracted.&#x20;

</details>


# TransferBtc

First step to transfer BTC to an address. Psbt will be returned in response for user's sign.

<mark style="color:green;">`POST`</mark> /api/transfer-btc

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name        | Type   | Description                                   |
| ----------- | ------ | --------------------------------------------- |
| `wallet_id` | string | The end user's wallet id                      |
| recv\_addr  | string | BTC address to send to.                       |
| amount      | int64  | Amount to send in sats                        |
| min\_conf   | int32  | Minimized confirmations to be as a legal UTXO |
| fee\_rate   | int64  | Fee rate in sat/vB                            |

**Request**

```json
{
    "wallet_id":"23a06ee3-050a-46f7-9eec-68d95471dd6c",
    "recv_addr": "bc1qp9zm6x5q6y02036l2q93936c4fs3acjr546yly",
    "amount": 20000000,
    "min_conf":6,
    "fee_rate":4
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": 0,
    "data": {
        "funded_psbt": ["cHNidP8BAHECAAAAAZGPYjWItkw0iOLPoanYSbYw+ibmnOqbnaix+sNsbImqAQAAAAD/////AgAtMQEAAAAAFgAUK2uwcXCF0j52o+XLVed9PD3MD57gJiEKAAAAABYAFAtC6UPwxusmdFdvhnMxvQmlkLS9AAAAAAABAN8CAAAAAAEBFDSqn+dU1Uxa/T8LJv3WP1PjR0wI3gfrGdECY7WMGZcCAAAAAP////8CgJaYAAAAAAAWABQra7BxcIXSPnaj5ctV5308PcwPnmpvUgsAAAAAFgAUC0LpQ/DG6yZ0V2+GczG9CaWQtL0CSDBFAiEA5mci4K5/n+MizCD/DvNDnxgx3YsGJ0CCtTr7u90liscCIFOHtC3VUOiZKC3Gf6s62MvJMPJVVgrDTPZ2LHeHujt2ASEC01BZ4Z28cGjI+8G+YVQTa165hkxiYML89466wQgVeMMAAAAAAQEfam9SCwAAAAAWABQLQulD8MbrJnRXb4ZzMb0JpZC0vQEDBAEAAAAiBgMogeczlXHujeNLANvMEPQj1w3V1sxRx9bs8zJVMR0E4BgAAAAAVAAAgAAAAIAAAACAAAAAAAAAAAAAAAA="]
    },
    "message": "",
    "traceid": "a73c5849-6a10-4bda-a411-d6c236277939"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# PublishTransferBtc

Second step to transfer BTC to an address. This will accept the user's signed psbt to broadcast in BTC network.

<mark style="color:green;">`POST`</mark> /api/publish-transfer-btc

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name        | Type    | Description                                        |
| ----------- | ------- | -------------------------------------------------- |
| `wallet_id` | string  | The end user's wallet id                           |
| final\_psbt | \[]byte | Signed and extracted transaction to be broadcasted |

{% hint style="warning" %}
As request data, signed psbt MUST be finalized and extracted by wallet.
{% endhint %}

**Request**

```json
{
    "wallet_id":"23a06ee3-050a-46f7-9eec-68d95471dd6c",
    "final_psbt": "AgAAAAABAZGPYjWItkw0iOLPoanYSbYw+ibmnOqbnaix+sNsbImqAQAAAAD/////AgAtMQEAAAAAFgAUK2uwcXCF0j52o+XLVed9PD3MD57gJiEKAAAAABYAFAtC6UPwxusmdFdvhnMxvQmlkLS9AkcwRAIgB++Pg8ATl+HjelizYtkuPRkYXg35b+24cMgZJe1H0cACIB3FgLysXyn7pp2tkMU42BeOOIz0NSr/beHbtL6YqhJCASEDKIHnM5Vx7o3jSwDbzBD0I9cN1dbMUcfW7PMyVTEdBOAAAAAA"
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": 0,
    "data": "ok",
    "message": "",
    "traceid": "7fe4b27a-f38d-4972-8158-1b30038ff440"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# JS SDK

JS toolkit as a DApp-connected wallet, allowing your app to quickly access the plugin wallet

### Main Functions

* Connect wallet
* Switch network
* Listen for account changes
* Listen transaction changes
* Get current assets
* Create invoice
* Send BTC Transfer
* Send taproot assets
* Sign messages
* Search assets
* Get invoices

### Requirements

* Modern web browser environment
* Install the bittap wallet extension
* A password and an existing account exist in the bittap wallet extension

### Links

* NPM package

{% embed url="<https://www.npmjs.com/package/@bittap/wallet-sdk>" %}

* Tutorials

{% embed url="<https://github.com/bittap-protocol/wallet-sdk/blob/main/Tutorials.en_US.md>" %}

{% embed url="<https://github.com/bittap-protocol/wallet-sdk/blob/main/Tutorials.zh_CN.md>" %}

* JSSDK Api Reference

{% embed url="<https://bittap-jssdk-doc.onebits.org/>" %}

* VUE Example

{% embed url="<https://bittap-vue.onebits.org/>" %}
Vue Demo
{% endembed %}

{% embed url="<https://github.com/bittap-protocol/wallet-sdk/tree/main/examples/vue3>" %}
Source code
{% endembed %}

* REACT Example

{% embed url="<https://bittap-react.onebits.org/>" %}
Demo
{% endembed %}

{% embed url="<https://github.com/bittap-protocol/wallet-sdk/tree/main/examples/react>" %}
Source code
{% endembed %}


