ckb-walletconnect-dapp-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha.1 • Public • Published

ckb-walletconnect-dapp-sdk

Description

An auxiliary library built on top of WalletConnect which wraps the protocol for integration within the CKB ecosystem.

Getting Started

Install

npm install ckb-walletconnect-dapp-sdk

Usage

  • Initialization
import {
  CkbWCSdk,
  GetAddressesParams,
  SignMessageParams,
  SignTransactionParams,
} from "ckb-walletconnect-dapp-sdk";
import { Web3Modal } from "@web3modal/standalone";

const web3Modal = new Web3Modal({
  projectId: process.env.PROJECT_ID,
  walletConnectVersion: 2,
});

const ckbWCSdk = await CkbWCSdk.init({
  projectId: process.env.PROJECT_ID,
  metadata: {
    name: "Demo Dapp",
    description: "Demo Dapp for WalletConnect",
    url: location.href,
    icons: [],
  },
})
  • Connect
const { uri, approval } = await ckbWCSdk.createConnect({
  network: "testnet",
  scriptBases: ['0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'],
});
await web3Modal.openModal({ uri });
await approval();
  • Disconnect
await ckbWCSdk.disconnect();
  • Methods
await ckbWCSdk.getAddresses(params as GetAddressesParams);
await ckbWCSdk.signMessage(params as SignMessageParams);
await ckbWCSdk.signTransaction(params as SignTransactionParams);
  • Info
const { chain, network, identity } = ckbWCSdk.getAccountInfo();
  • Handle Events
walletSDK.emitter.on("connect", handler);
walletSDK.emitter.on("disconnect", handler);
walletSDK.emitter.on("accountChanged", handler);
walletSDK.emitter.on("addressesChanged", handler);

Readme

Keywords

none

Package Sidebar

Install

npm i ckb-walletconnect-dapp-sdk

Weekly Downloads

1

Version

0.0.1-alpha.1

License

MIT

Unpacked Size

80.4 kB

Total Files

18

Last publish

Collaborators

  • echo_fefe