Options
All
  • Public
  • Public/Protected
  • All
Menu

@stacks/bns

A package for interacting with the BNS contract on the Stacks blockchain.

What is BNS?

The Blockchain Naming System (BNS) is a network system that binds Stacks usernames to off-chain state without relying on any central points of control.

Installation

npm install --save @stacks/bns

Example Usage

import { canRegisterName } from '@stacks/bns';
import { StacksTestnet } from '@stacks/network';

const network = new StacksMainnet();

const fullyQualifiedName = 'name.id';
const result = await canRegisterName({ fullyQualifiedName, network });
import { buildRegisterNameTX } from '@stacks/bns';
import { StacksTestnet } from '@stacks/network';

const network = new StacksMainnet();

const name = 'name.id';
const salt =  'example-salt'
const zonefile =  'example-zonefile'
const publicKey = 'SPF0324DSC4K505TP6A8C7GAK4R95E38TGNZP7RE'

// construct an unsigned bns register-name transaction
// note: builder functions build transactions with AnchorMode set to Any
const unsignedTX = await buildRegisterNameTX({ name, salt, zonefile, publicKey, network });

Index

Variables

Const BNS_CONTRACT_NAME

BNS_CONTRACT_NAME: "bns" = 'bns'

Functions

buildImportNameTx

buildPreorderNameTx

  • Generates a name preorder transaction. First step in registering a name. This transaction does not reveal the name that is about to be registered. And it sets the amount of STX to be burned for the registration.

    Resolves to the generated StacksTransaction

    Parameters

    Returns Promise<StacksTransaction>

buildPreorderNamespaceTx

  • Generates a namespace preorder transaction. First step in registering a namespace. This transaction does not reveal the namespace that is about to be registered. And it sets the amount of STX to be burned for the registration.

    Resolves to the generated StacksTransaction

    Parameters

    Returns Promise<StacksTransaction>

buildReadyNamespaceTx

  • Generates a ready namespace transaction. Final step in namespace registration. This completes the namespace registration and makes the namespace available for name registrations.

    Resolves to the generated StacksTransaction

    Parameters

    Returns Promise<StacksTransaction>

buildRegisterNameTx

buildRenewNameTx

buildRevealNamespaceTx

buildRevokeNameTx

buildTransferNameTx

  • Generates a name transfer transaction. This changes the owner of the registered name.

    Since the underlying NFT will be transferred, you will be required to add a post-condition to this transaction before broadcasting it.

    Resolves to the generated StacksTransaction

    Parameters

    Returns Promise<StacksTransaction>

buildUpdateNameTx

canRegisterName

getNamePrice

getNamespacePrice

Generated using TypeDoc