npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nervina-labs/ckb-dex

v0.7.0

Published

The JavaScript SDK for CKB DEX

Downloads

938

Readme

CKB DEX SDK

CI NPM

CKB DEX SDK is a comprehensive web development kit, which helps developers interact with the CKB DEX contract in JavaScript/TypeScript environments.

The SDK provides methods for making orders, taking orders, and canceling orders. Developers can use common lock scripts, such as official secp256k1/blake160 lock, JoyID lock, etc., to interact with the CKB DEX contract.

You can use the DEX to swap fungible tokens(SUDT, XUDT, ccBTC, etc.) and non-fungible tokens(Spore, mNFT, etc.) with CKB native asset and JoyID lock is recommended to hold and swap CKB assets.

You can build the maker transactions to transfer FT or NFT assets to DEX lock script whose args contains owner address, price(based on CKB native asset), setup, etc. Anyone can build a taker transaction, as long as the price required in the DEX lock args is met. You can cancel the maker transactions at any time before the taker transactions are executed.

Installation

$ npm i @nervina-labs/ckb-dex
# or
$ yarn add @nervina-labs/ckb-dex
# or
$ pnpm add @nervina-labs/ckb-dex

Development

Connect the JoyID Wallet

You can connect JoyID wallet using @joyid/ckb SDK connect function and then you can get the ConnectResponseData to build maker and taker transactions later.

Build and Sign transactions

You can use buildMakerTx, buildCancelTx and buildTakerTx methods to place, cancel and take orders with the ConnectResponseData and the methods will generate CKB raw transaction for you to be signed later.

You must set the asset type(CKBAsset) when calling buildXXXTx methods and the CKBAsset is defined as follows:

export enum CKBAsset {
  XUDT,
  SUDT,
  XUDT_CC, // ccBTC
  SPORE,
  MNFT,
}

The examples demonstrate how to build FT and NFT maker, taker transactions with JoyID lock and the local test private keys are for simplicity, please DON'T use the local private keys in your production DApp.

You can call the signRawTransaction method to sign the raw tx with JoyID wallet through @joyid/ckb SDK, and you can send the signed transaction through CKB RPC.