# bns | Stacks.js 1.4.1 Library Reference
Documentation for Stacks.js 1.4.1 Library Reference

# `@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

### Enumerations

- BnsContractAddress

### Interfaces

- BnsContractCallOptions
- BnsReadOnlyOptions
- CanRegisterNameOptions
- GetNamePriceOptions
- GetNamespacePriceOptions
- ImportNameOptions
- PreorderNameOptions
- PreorderNamespaceOptions
- PriceFunction
- ReadyNamespaceOptions
- RegisterNameOptions
- RenewNameOptions
- RevealNamespaceOptions
- RevokeNameOptions
- TransferNameOptions
- UpdateNameOptions

### Variables

- BNS_CONTRACT_NAME

### Functions

- buildImportNameTx
- buildPreorderNameTx
- buildPreorderNamespaceTx
- buildReadyNamespaceTx
- buildRegisterNameTx
- buildRenewNameTx
- buildRevealNamespaceTx
- buildRevokeNameTx
- buildTransferNameTx
- buildUpdateNameTx
- canRegisterName
- getNamePrice
- getNamespacePrice

## Variables

### Const BNS_CONTRACT_NAME

BNS_CONTRACT_NAME: "bns" = 'bns'

- Defined in packages/bns/src/index.ts:31

## Functions

### buildImportNameTx

- buildImportNameTx(__namedParameters: ImportNameOptions ): Promise< StacksTransaction >

- - Defined in packages/bns/src/index.ts:413

  Generates a namespace name import transaction. An optional step in namespace registration.

  Resolves to the generated StacksTransaction

  #### Parameters

  - ##### __namedParameters: ImportNameOptions

  #### Returns Promise< StacksTransaction >

### buildPreorderNameTx

- buildPreorderNameTx(__namedParameters: PreorderNameOptions ): Promise< StacksTransaction >

- - Defined in packages/bns/src/index.ts:506

  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

  - ##### __namedParameters: PreorderNameOptions

  #### Returns Promise< StacksTransaction >

### buildPreorderNamespaceTx

- buildPreorderNamespaceTx(__namedParameters: PreorderNamespaceOptions ): Promise< StacksTransaction >

- - Defined in packages/bns/src/index.ts:290

  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

  - ##### __namedParameters: PreorderNamespaceOptions

  #### Returns Promise< StacksTransaction >

### buildReadyNamespaceTx

- buildReadyNamespaceTx(__namedParameters: ReadyNamespaceOptions ): Promise< StacksTransaction >

- - Defined in packages/bns/src/index.ts:462

  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

  - ##### __namedParameters: ReadyNamespaceOptions

  #### Returns Promise< StacksTransaction >

### buildRegisterNameTx

- buildRegisterNameTx(__namedParameters: RegisterNameOptions ): Promise< StacksTransaction >

- - Defined in packages/bns/src/index.ts:557

  Generates a name registration transaction. Second and final step in registering a name.

  Resolves to the generated StacksTransaction

  #### Parameters

  - ##### __namedParameters: RegisterNameOptions

  #### Returns Promise< StacksTransaction >

### buildRenewNameTx

- buildRenewNameTx(__namedParameters: RenewNameOptions ): Promise< StacksTransaction >

- - Defined in packages/bns/src/index.ts:768

  Generates a name renew transaction. This renews a name registration.

  Resolves to the generated StacksTransaction

  #### Parameters

  - ##### __namedParameters: RenewNameOptions

  #### Returns Promise< StacksTransaction >

### buildRevealNamespaceTx

- buildRevealNamespaceTx(__namedParameters: RevealNamespaceOptions ): Promise< StacksTransaction >

- - Defined in packages/bns/src/index.ts:340

  Generates a namespace reveal transaction. Second step in registering a namespace.

  Resolves to the generated StacksTransaction

  #### Parameters

  - ##### __namedParameters: RevealNamespaceOptions

  #### Returns Promise< StacksTransaction >

### buildRevokeNameTx

- buildRevokeNameTx(__namedParameters: RevokeNameOptions ): Promise< StacksTransaction >

- - Defined in packages/bns/src/index.ts:719

  Generates a name revoke transaction. This revokes a name registration.

  Resolves to the generated StacksTransaction

  #### Parameters

  - ##### __namedParameters: RevokeNameOptions

  #### Returns Promise< StacksTransaction >

### buildTransferNameTx

- buildTransferNameTx(__namedParameters: TransferNameOptions ): Promise< StacksTransaction >

- - Defined in packages/bns/src/index.ts:666

  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

  - ##### __namedParameters: TransferNameOptions

  #### Returns Promise< StacksTransaction >

### buildUpdateNameTx

- buildUpdateNameTx(__namedParameters: UpdateNameOptions ): Promise< StacksTransaction >

- - Defined in packages/bns/src/index.ts:612

  Generates a name update transaction. This changes the zonefile for the registered name.

  Resolves to the generated StacksTransaction

  #### Parameters

  - ##### __namedParameters: UpdateNameOptions

  #### Returns Promise< StacksTransaction >

### canRegisterName

- canRegisterName(__namedParameters: CanRegisterNameOptions ): Promise<boolean>

- - Defined in packages/bns/src/index.ts:127

  Check if name can be registered

  #### Parameters

  - ##### __namedParameters: CanRegisterNameOptions

  #### Returns Promise<boolean>

  that resolves to true if the operation succeeds

### getNamePrice

- getNamePrice(__namedParameters: GetNamePriceOptions ): Promise<BN>

- - Defined in packages/bns/src/index.ts:227

  Get price of name registration in microstacks

  #### Parameters

  - ##### __namedParameters: GetNamePriceOptions

  #### Returns Promise<BN>

  that resolves to a BN object number of microstacks if the operation succeeds

### getNamespacePrice

- getNamespacePrice(__namedParameters: GetNamespacePriceOptions ): Promise<BN>

- - Defined in packages/bns/src/index.ts:176

  Get price of namespace registration in microstacks

  #### Parameters

  - ##### __namedParameters: GetNamespacePriceOptions

  #### Returns Promise<BN>

  that resolves to a BN object number of microstacks if the operation succeeds

Generated using TypeDoc