Skip to content

The ultimate JavaScript SDK for .bit

License

Notifications You must be signed in to change notification settings

vecpeng/dotbit.js

 
 

Repository files navigation

dotbit: .bit JavaScript SDK

NPM npm

A complete .bit SDK and utilities in JavaScript (and TypeScript).

This is the new version of .bit (Previously DAS) JavaScript SDK. If you are looking for the source code of npm package das-sdk(Deprecated), please check out the branch das-sdk.

Features

  • Query .bit account info, including owner, manager, status, and more.
  • Query .bit account records, including addresses, profiles, dwebs and custom data.
  • Enable .bit Sub-Account for a specific account.
  • Mint a sub-account of a .bit main account.
  • Query all the sub-accounts of a .bit main account.
  • Manage the ownership of a .bit account(sub-account included).
  • Manage the records of a .bit account(sub-account included).
  • Register a .bit account with CKB. (Coming soon)

Installation

npm install dotbit --save

QuickStart

Query different records:

// import { createInstance } from 'dotbit' // For ES Module
const { createInstance } = require('dotbit')
const dotbit = createInstance()

// Get all .bit account records
dotbit.records('imac.bit').then(console.log)

// Get all `eth` addresses of a .bit account
dotbit.addrs('imac.bit', 'eth').then(console.log)

// Get `twitter` account of a .bit account
dotbit.profiles('imac.bit', 'twitter').then(console.log)

Mint a sub-account in testnet:

// import { createInstance, ProviderSigner, BitNetwork } from 'dotbit' // For ES Module
const { createInstance, ProviderSigner, BitNetwork } = require('dotbit')

const signer = new ProviderSigner(window.ethereum)
const dotbit = createInstance({
  network: BitNetwork.testnet,
  signer
})

const bitAccount = dotbit.account('imac.bit')

bitAccount.mintSubAccount({
  account: '001.imac.bit',
  keyInfo: {
    key: '0x...',
    coin_type: '60',
  },
  registerYears: 1,
}).then(console.log)

coin_type is the Coin Types defined in slip44 to distinguish different Coins/Chains. For all coin_type .bit supported, please check const.ts

For more complete usages, please check out the examples: For browser, For Node.js.

Get help

Please join our Discord channel, or raise an issue: Issues

Contribute

This SDK is still under heavily development. Any contribution including PR is welcome.

Please raise an issue if you find any bugs or have any suggestions.

License

MIT License (including all dependencies).

About

The ultimate JavaScript SDK for .bit

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 94.1%
  • JavaScript 5.3%
  • HTML 0.6%