-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #280 from ckb-cell/docs/readme-to-assets-api
docs: link to btc-assets-api repo in the root/service README
- Loading branch information
Showing
2 changed files
with
23 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
## About | ||
|
||
The `@rgbpp-sdk/service` package provides a wrapped class to interact with `Bitcoin/RGB++ Assets Service` (BtcAssetsApi). It offers various features for interacting with Bitcoin and RGB++ assets: | ||
The `@rgbpp-sdk/service` package provides a wrapped class to interact with [`Bitcoin/RGB++ Assets Service`](https://github.com/ckb-cell/btc-assets-api) (BtcAssetsApi). It offers various features for interacting with Bitcoin and RGB++ assets: | ||
|
||
- **Retrieve Blockchain Information** including Bitcoin chain info, blocks, headers, transactions, addresses, and RGB++ assets | ||
- **Handle transactions** by posting to `/bitcoin/v1/transaction` or `/rgbpp/v1/transaction/ckb-tx` | ||
|
@@ -11,7 +11,7 @@ The `@rgbpp-sdk/service` package provides a wrapped class to interact with `Bitc | |
- More detailed API documentation can be found on [Testnet](https://api.testnet.rgbpp.io/docs), [Signet](https://api.signet.rgbpp.io/docs) and [Mainnet](https://api.rgbpp.io/docs) | ||
|
||
> [!NOTE] | ||
> `Bitcoin/RGB++ Assets Service` is designed to streamline the transaction workflow. Developers have the option to implement its features by themselves without limitation. | ||
> [`Bitcoin/RGB++ Assets Service`](https://github.com/ckb-cell/btc-assets-api) is an open-source project designed to streamline the transaction workflow for Bitcoin and RGB++ Assets. Developers have the option to enhance it by implementing its features by themselves without limitations. For those who prefer to deploy their own `Bitcoin/RGB++ Assets Service`, please follow the instructions at the [Deployment](https://github.com/ckb-cell/btc-assets-api#deployment) section in the btc-assets-api repository. | ||
## Installation | ||
|
||
|
@@ -26,49 +26,46 @@ $ pnpm add @rgbpp-sdk/service | |
|
||
## Get started | ||
|
||
### Get an access token | ||
|
||
#### Testnet | ||
|
||
You can get a testnet access token through the [/token/generate](https://api.testnet.rgbpp.io/docs/static/index.html#/Token/post_token_generate) API directly. | ||
### Get a service URL | ||
|
||
#### Signet | ||
You can start using the `Bitcoin/RGB++ Assets Service` by accessing one of our deployed services. For those who prefer to deploy their own `Bitcoin/RGB++ Assets Service`, the documentation for deployment can be found at: [Deployment - ckb-cell/btc-assets-api](https://github.com/ckb-cell/btc-assets-api#deployment). | ||
|
||
And you can get an access token of BTC Signet network through the [/token/generate](https://api.signet.rgbpp.io/docs/static/index.html#/Token/post_token_generate) API directly. | ||
- Testnet: https://api.testnet.rgbpp.io | ||
- Signet: https://api.signet.rgbpp.io | ||
- Mainnet: https://api.rgbpp.io | ||
|
||
#### Mainnet | ||
|
||
The mainnet BtcAssetsApi is currently limited to verified apps only. | ||
### Get an access token | ||
|
||
When your app development is ready on testnet, and requires a mainnet access token, | ||
please email us at [email protected] to request a mainnet JWT token. | ||
You need an access token to interact with the service. The testnet/signet services are currently free to access, you can get an access token of the target network through the following documentation URLs: | ||
|
||
In the email, please provide the following information about your app: | ||
- Testnet: [/token/generate](https://api.testnet.rgbpp.io/docs/static/index.html#/Token/post_token_generate) | ||
- Signet: [/token/generate](https://api.signet.rgbpp.io/docs/static/index.html#/Token/post_token_generate) | ||
|
||
- `name`: Your app name, e.g. "rgbpp-app" | ||
- `domain`: Your app domain, e.g. "rgbpp.app" (without protocol prefix and port suffix) | ||
As to the mainnet service, it's currently limited to verified apps only. When your app development is ready on testnet, and requires a mainnet access token, please email us at `[email protected]` to request a mainnet JWT token. In the email, please provide the following information about your app: | ||
|
||
- Name: Your app name, e.g. "rgbpp-app" | ||
- Domain: Your app domain, e.g. "rgbpp.app" | ||
|
||
### Initialize the service | ||
|
||
#### Browser | ||
|
||
Initialize BtcAssetsApi service with your access token: | ||
Initialize the service with the URL and your access token in browser environment: | ||
|
||
```typescript | ||
import { BtcAssetsApi } from '@rgbpp-sdk/service'; | ||
|
||
const service = BtcAssetsApi.fromToken('https://your-btc-assets-api.url', 'your_access_token'); | ||
const service = BtcAssetsApi.fromToken('https://api.testnet.rgbpp.io', 'your_access_token'); | ||
``` | ||
|
||
#### Node.js | ||
|
||
You should pass `origin` when initializing BtcAssetsApi service in Node.js: | ||
When initializing the service in Node.js, you should also pass the `origin` prop: | ||
|
||
```typescript | ||
import { BtcAssetsApi } from '@rgbpp-sdk/service'; | ||
|
||
const service = BtcAssetsApi.fromToken('https://your-btc-assets-api.url', 'your_access_token', 'https://your.app'); | ||
const service = BtcAssetsApi.fromToken('https://api.testnet.rgbpp.io', 'your_access_token', 'https://your_app.origin'); | ||
``` | ||
|
||
The `origin` prop is used to verify your token's corresponding `domain`. | ||
|
@@ -81,9 +78,9 @@ Note the format difference `domain` and `origin`: | |
- `domain`: `your.app`, without protocol (`https://`, `http://`, etc.) | ||
- `origin`: `https://your.app`, with protocol `https://` | ||
|
||
### Start using the service | ||
### Interact with the service | ||
|
||
Once the initialization is complete, you can query from the service: | ||
Once initialized, you can start accessing the service: | ||
|
||
```typescript | ||
// Query the balance of an address | ||
|
@@ -98,7 +95,7 @@ console.log(res); | |
// } | ||
``` | ||
|
||
All available APIs in the [BtcAssetsApi](#types) section. | ||
All available APIs can be found in the [Types](#types) section. | ||
|
||
### Handling service errors | ||
|
||
|
b6d103c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New snapshot version of the rgbpp-sdk packages have been released:
0.0.0-snap-20240815022542
0.0.0-snap-20240815022542
0.0.0-snap-20240815022542
0.0.0-snap-20240815022542