Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BlockstackNetwork

Use the methods in class to build third-party wallets or in DApps that register names.

Hierarchy

  • BlockstackNetwork

Index

Constructors

constructor

  • new BlockstackNetwork(apiUrl: string, broadcastServiceUrl: string, bitcoinAPI: BitcoinNetwork, network?: Network): BlockstackNetwork
  • Parameters

    • apiUrl: string
    • broadcastServiceUrl: string
    • bitcoinAPI: BitcoinNetwork
    • Default value network: Network = networks.bitcoin

    Returns BlockstackNetwork

Properties

DUST_MINIMUM

DUST_MINIMUM: number

MAGIC_BYTES

MAGIC_BYTES: string

blockstackAPIUrl

blockstackAPIUrl: string

broadcastServiceUrl

broadcastServiceUrl: string

btc

btc: BitcoinNetwork

excludeUtxoSet

excludeUtxoSet: UTXO[]

includeUtxoMap

includeUtxoMap: object

Type declaration

  • [address: string]: UTXO[]

Methods

Private broadcastNameRegistration

  • broadcastNameRegistration(preorderTransaction: string, registerTransaction: string, zoneFile: string): Promise<any>
  • Sends the preorder and registration transactions and zone file for a Blockstack name registration along with the to the transaction broadcast service.

    The transaction broadcast:

    • immediately broadcasts the preorder transaction
    • broadcasts the register transactions after the preorder transaction has an appropriate number of confirmations
    • broadcasts the zone file to the Atlas network after the register transaction has an appropriate number of confirmations

    This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • preorderTransaction: string

      the hex-encoded, signed preorder transaction generated using the makePreorder function

    • registerTransaction: string

      the hex-encoded, signed register transaction generated using the makeRegister function

    • zoneFile: string

      the zone file to be broadcast to the Atlas network

    Returns Promise<any>

    Returns a Promise that resolves to an object with a transaction_hash key containing the transaction hash of the broadcasted transaction.

    In the event of an error, it rejects with:

    • a RemoteServiceError if there is a problem with the transaction broadcast service
    • MissingParameterError if you call the function without a required parameter

Private broadcastServiceFetchHelper

  • broadcastServiceFetchHelper(endpoint: string, body: any): Promise<any | Error>
  • Performs a POST request to the given URL. This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • endpoint: string

      the name of

    • body: any

    Returns Promise<any | Error>

    Returns a Promise that resolves to the object requested. In the event of an error, it rejects with:

    • a RemoteServiceError if there is a problem with the transaction broadcast service
    • MissingParameterError if you call the function without a required parameter

Private broadcastTransaction

  • broadcastTransaction(transaction: string, transactionToWatch?: string, confirmations?: number): Promise<any>
  • Broadcasts a signed bitcoin transaction to the network optionally waiting to broadcast the transaction until a second transaction has a certain number of confirmations.

    This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • transaction: string

      the hex-encoded transaction to broadcast

    • Default value transactionToWatch: string = null

      the hex transaction id of the transaction to watch for the specified number of confirmations before broadcasting the transaction

    • Default value confirmations: number = 6

      the number of confirmations transactionToWatch must have before broadcasting transaction.

    Returns Promise<any>

    Returns a Promise that resolves to an object with a transaction_hash key containing the transaction hash of the broadcasted transaction.

    In the event of an error, it rejects with:

    • a RemoteServiceError if there is a problem with the transaction broadcast service
    • MissingParameterError if you call the function without a required parameter

Private broadcastZoneFile

  • broadcastZoneFile(zoneFile?: string, transactionToWatch?: string): Promise<any>
  • Broadcasts a zone file to the Atlas network via the transaction broadcast service. This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • Optional zoneFile: string

      the zone file to be broadcast to the Atlas network

    • Default value transactionToWatch: string = null

      the hex transaction id of the transaction to watch for confirmation before broadcasting the zone file to the Atlas network

    Returns Promise<any>

    Returns a Promise that resolves to an object with a transaction_hash key containing the transaction hash of the broadcasted transaction.

    In the event of an error, it rejects with:

    • a RemoteServiceError if there is a problem with the transaction broadcast service
    • MissingParameterError if you call the function without a required parameter

getAccountAt

  • getAccountAt(address: string, blockHeight: number): Promise<any[]>
  • Get the state(s) of an account at a particular block height. This includes the state of the account beginning with this block's transactions, as well as all of the states the account passed through when this block was processed (if any).

    This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • address: string

      the account's address

    • blockHeight: number

      the block to query

    Returns Promise<any[]>

    a promise that resolves to an Array of Objects, where each Object encodes states of the account at this block.

getAccountBalance

  • getAccountBalance(address: string, tokenType: string): Promise<BN>
  • Get the number of tokens owned by an account. If the account does not exist or has no tokens of this type, then 0 will be returned.

    This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • address: string

      the account's address

    • tokenType: string

      the type of token to query.

    Returns Promise<BN>

    a promise that resolves to a BigInteger that encodes the number of tokens held by this account.

getAccountHistoryPage

  • getAccountHistoryPage(address: string, page: number): Promise<any[]>
  • Get a page of an account's transaction history. This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • address: string

      the account's address

    • page: number

      the page number. Page 0 is the most recent transactions

    Returns Promise<any[]>

    a promise that resolves to an Array of Objects, where each Object encodes states of the account at various block heights (e.g. prior balances, txids, etc)

getAccountStatus

  • getAccountStatus(address: string, tokenType: string): Promise<any>
  • Get the status of an account for a particular token holding. This includes its total number of expenditures and credits, lockup times, last txid, and so on.

    This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • address: string

      the account

    • tokenType: string

      the token type to query

    Returns Promise<any>

    a promise that resolves to an object representing the state of the account for this token

getAccountTokens

  • Get the set of token types that this account owns. This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • address: string

      the account's address

    Returns Promise<AccountTokens>

    a promise that resolves to an Array of Strings, where each item encodes the type of token this account holds (excluding the underlying blockchain's tokens)

getDefaultBurnAddress

  • getDefaultBurnAddress(): string
  • This is intended for use in third-party wallets or in DApps that register names.

    Returns string

getGracePeriod

  • getGracePeriod(_fullyQualifiedName?: string): Promise<number>
  • How many blocks can pass between a name expiring and the name being able to be re-registered by a different owner. This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • Optional _fullyQualifiedName: string

    Returns Promise<number>

    a promise to the number of blocks

getNameInfo

  • getNameInfo(fullyQualifiedName: string): Promise<any>
  • Get WHOIS-like information for a name, including the address that owns it, the block at which it expires, and the zone file anchored to it (if available).

    This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • fullyQualifiedName: string

      the name to query. Can be on-chain of off-chain.

    Returns Promise<any>

    a promise that resolves to the WHOIS-like information

getNamePrice

  • getNamePrice(fullyQualifiedName: string): Promise<PriceInfo>
  • Get the price of a name. This is intended for use in third-party wallets or in DApps that register names. This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • fullyQualifiedName: string

      the name to query

    Returns Promise<PriceInfo>

    a promise to an Object with { units: String, amount: BigInteger }, where .units encodes the cryptocurrency units to pay (e.g. BTC, STACKS), and .amount encodes the number of units, in the smallest denominiated amount (e.g. if .units is BTC, .amount will be satoshis; if .units is STACKS, .amount will be microStacks)

Private getNamePriceV1

  • getNamePriceV1(fullyQualifiedName: string): Promise<PriceInfo>
  • Get the price of a name via the legacy /v1/prices API endpoint. This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • fullyQualifiedName: string

      the name to query

    Returns Promise<PriceInfo>

    a promise to an Object with { units: String, amount: BigInteger }

Private getNamePriceV2

  • getNamePriceV2(fullyQualifiedName: string): Promise<PriceInfo>
  • Get the price of a name via the /v2/prices API endpoint. This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • fullyQualifiedName: string

      the name to query

    Returns Promise<PriceInfo>

    a promise to an Object with { units: String, amount: BigInteger }

getNamesOwned

  • getNamesOwned(address: string): Promise<string[]>
  • Get the names -- both on-chain and off-chain -- owned by an address. This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • address: string

      the blockchain address (the hash of the owner public key)

    Returns Promise<string[]>

    a promise that resolves to a list of names (Strings)

getNamespaceBurnAddress

  • getNamespaceBurnAddress(namespace: string): Promise<string>
  • Get the blockchain address to which a name's registration fee must be sent (the address will depend on the namespace in which it is registered.)

    This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • namespace: string

      the namespace ID

    Returns Promise<string>

    a promise that resolves to an address (String)

getNamespaceInfo

  • getNamespaceInfo(namespaceID: string): Promise<any>
  • Get the pricing parameters and creation history of a namespace. This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • namespaceID: string

      the namespace to query

    Returns Promise<any>

    a promise that resolves to the namespace information.

getNamespacePrice

  • getNamespacePrice(namespaceID: string): Promise<PriceInfo>
  • Get the price of a namespace. This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • namespaceID: string

      the namespace to query

    Returns Promise<PriceInfo>

    a promise to an Object with { units: String, amount: BigInteger }, where .units encodes the cryptocurrency units to pay (e.g. BTC, STACKS), and .amount encodes the number of units, in the smallest denominiated amount (e.g. if .units is BTC, .amount will be satoshis; if .units is STACKS, .amount will be microStacks)

Private getNamespacePriceV1

  • getNamespacePriceV1(namespaceID: string): Promise<PriceInfo>
  • Get the price of a namespace via the legacy /v1/prices API endpoint. This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • namespaceID: string

      the namespace to query

    Returns Promise<PriceInfo>

    a promise to an Object with { units: String, amount: BigInteger }

Private getNamespacePriceV2

  • getNamespacePriceV2(namespaceID: string): Promise<PriceInfo>
  • Get the price of a namespace via the /v2/prices API endpoint. This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • namespaceID: string

      the namespace to query

    Returns Promise<PriceInfo>

    a promise to an Object with { units: String, amount: BigInteger }

getNetworkedUTXOs

  • getNetworkedUTXOs(address: string): Promise<UTXO[]>

getTransactionInfo

getZonefile

  • getZonefile(zonefileHash: string): Promise<string>
  • Get a zone file, given its hash. Throws an exception if the zone file obtained does not match the hash.

    This is intended for use in third-party wallets or in DApps that register names.

    Parameters

    • zonefileHash: string

      the ripemd160(sha256) hash of the zone file

    Returns Promise<string>

    a promise that resolves to the zone file's text

Generated using TypeDoc