bob-collective / bob

BOB is a hybrid L2 that combines the security of Bitcoin with the versatility of Ethereum.
https://app.gobob.xyz/
78 stars 39 forks source link

Unified REST APIs for working with Bitcoin #55

Closed nud3l closed 11 months ago

nud3l commented 12 months ago

Is your feature request related to a problem? Please describe. Protocols built on top of Bitcoin have various APIs available, but they are early stage and often lack documentation. Moreover, they are not well integrated with existing REST APIs like electrs.

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

nakul1010 commented 11 months ago

Jotting down currently known APIs pros & cons for designing the Unified API.

Mempool.space

Link Pros

Cons

Link

Pros

Cons

BlockCypher

Link

Pros

Cons

Unisat

Link It's a wallet Api. Pros

Cons

Unified API

Link: We need to design. :)

The API should support the following important functionalities

References

nakul1010 commented 11 months ago

As discussed on Discord, the following methods in electrs should be extended to handle

cc: @nud3l and @ns212

nud3l commented 11 months ago

What about all the other APIs, e.g., the ones exposed by unisat to also inscribe BRC20 and ordinals plus the functions around BRC20 lists, holders, history, ...? https://docs.unisat.io/dev/open-api/brc20

I'd like to please have a more extensive proposal from you @nakul1010 @ns212 that covers:

  1. The proposed new endpoints
  2. The order in which you think those should be implemented
nakul1010 commented 11 months ago

I was trying to add the APIs without changing much of the electrum structure and without adding an indexer. But if u want most of the functionality, then an indexer needs to be added.

The following methods in the local environment can be accessible at endpoint http://localhost:3003.

Method::Get inscriptionUtxo/{address}

Method::Get bestheight

Method::Get /inscriptions/<FROM>

Method::Get brc20/list

Method::Get brc20balance/<address>/<ticker>

----------

`Method::Get` `inscriptions/<address>/<ticker>`
- get inscriptions by account
- Output
```json
{
  "code": 0,
  "msg": "ok",
  "data": {
    "cursor": 0,
    "total": 29,
    "totalConfirmed": 29,
    "totalUnconfirmed": 0,
    "totalUnconfirmedSpend": 0,
    "utxo": [
      {
        "txid": "0328b6bb6d749cf2d2535eb5cef939a0f5db5bdf4540b80ff773c3a85888c2bb",
        "satoshi": 546,
        "scriptType": "0020",
        "inscriptions": [
          {
            "inscriptionNumber": 22818979,
            "inscriptionId": "a6cba6a3bd2cde4b7a600638838de5387aeb4f061968fb894f0cf14e0ee3b0edi0",
            "isBRC20": true
          }
        ]
      },
      {
        "txid": "c42584248fb93e0b8e51db8344d53cdaa3eb12e5e73e6ae72d855d23aa1a9b0b",
        "satoshi": 546,
        "inscriptions": [
          {
            "inscriptionNumber": 23338832,
            "inscriptionId": "9774f5827c242962d3f12f599221370f9e9d8b121605e6e29e6a32863717d96ei0",
            "isBRC20": true
          }
        ]
      },
    ]
  }
}

Method::Post create_inscriptions/<address>/<json_string>

{
  "code": 0,
  "msg": "ok",
  "data": {
    "Inscriptions": [
       {
           "inscriptionId": "9774f5827c242962d3f12f599221370f9e9d8b121605e6e29e6a32863717d96ei0",
           "index": 0
       },
       {
           "inscriptionId": "9774f5827c242962d3f12f599221370f9e9d8b121605e6e29e6a32863717d96ei0",
           "index":1
       },
       {
           "inscriptionId": "9774f5827c242962d3f12f599221370f9e9d8b121605e6e29e6a32863717d96ei0",
           "index": 2
       }
    ]
  }
}

Method::Post create_batch_inscriptions/<address>/<json_string>/


Method::Post brc20/deploy/<address>/<amount>

Method::Post brc20/transfer/<address>/<amount>

Method::Post brc20/mint/<address>/<amount>


Still Unknowns


Proposal to implement

ToDos in serial order

nakul1010 commented 11 months ago

Closed in #73