@nervina-labs/cota-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.9.2 • Public • Published

cota-sdk-js

License CI NPM

JavaScript SDK for CoTA.

CoTA Docs

Installation

$ npm i @nervina-labs/cota-sdk
# or
$ yarn add @nervina-labs/cota-sdk

Prerequisites

CoTA SDK needs to run the services as blow:

  • CKB Node: Nervos CKB Node
  • CKB Indexer: Fetch live cells and transactions with filters
  • CoTA Syncer: Parse CoTA witness SMT data from CKB blockchain history transactions and save it to the mysql database
  • CoTA Registry Aggregator: Generate SMT info using the data from the database for registry and provide RPC APIs
  • CoTA Aggregator: Generate SMT info using the data from the database for CoTA NFT actions and provide RPC APIs

The above services are valid only when synced to the latest block and we strongly suggest to run the services in mainnet by yourself.

Public ckb node url and ckb indexer url as blow can be used to develop and test

# mainnet:
https://mainnet.ckbapp.dev/rpc       --->  ckb mainnet node rpc
https://mainnet.ckbapp.dev/indexer   --->  ckb mainnet indexer rpc

# testnet:
https://testnet.ckbapp.dev/rpc       --->  ckb testnet node rpc
https://testnet.ckbapp.dev/indexer   --->  ckb testnet indexer rpc

Public aggregator rpc url as blow can be used to develop and test

# mainnet:
https://cota.nervina.dev/mainnet-aggregator            --->  cota aggregator rpc
https://cota.nervina.dev/mainnet-registry-aggregator   --->  cota registry aggregator rpc

# testnet:
https://cota.nervina.dev/aggregator                    --->  cota aggregator rpc
https://cota.nervina.dev/registry-aggregator           --->  cota registry aggregator rpc

CoTA NFT Flow

                     Register CoTA cell firstly
1. Alice & Bob & Tom ----------------------------------> Alice CoTA cell & Bob CoTA cell & Tom CoTA cell

          Define CoTA NFT               Mint CoTA NFT A to receivers
2. Alice -----------------------> NFT A -----------------------------------> Receivers (Bob)

                    Claim NFT A                                  Withdraw NFT A to Tom
       Action1 |-------------------------> Bob hold NFT A now ----------------------------------> Bob doesn't hold NFT A now
      |             Transfer NFT A to Tom
3. Bob Action2 |-----------------------------------> Bob doesn't hold NFT A now
      |           Update CoTA NFT A information
       Action3 |-----------------------------------> Bob hold CoTA NFT A with new information

                    Claim NFT A                                 Withdraw NFT A to other receivers
        Action1 |-------------------------> Tom hold NFT A now ----------------------------------> Tom doesn't hold NFT A now
4. Tom |         Transfer NFT A to other receivers
        Action2 |-----------------------------------> Tom doesn't hold NFT A now

  • Registry: Every address should be registered firstly
  • Define: The issuer can define a collection NFTs with total/name/description/image etc.
  • Mint: The issuer mint the defined NFTs to the receivers (withdraw to the receivers actually)
  • Claim: The receiver can claim the NFT from the mint, and now the receiver hold the NFT
  • Update: The holder of NFT can update the information (characteristic/state etc.)
  • Withdraw: The holder of NFT can withdraw the NFT to any other CKB address
  • Transfer: To simplify, transfer combines the claim and withdraw into one operation. The receiver can claim the NFT from the mint and withdraw the same NFT to others in a transaction.

Examples

Readme

Keywords

none

Package Sidebar

Install

npm i @nervina-labs/cota-sdk

Weekly Downloads

37

Version

0.9.2

License

MIT

Unpacked Size

83.8 kB

Total Files

65

Last publish

Collaborators

  • jjyr
  • dylandev
  • ins893412899
  • coldsnap666
  • yuche
  • keith_chen