Options
All
  • Public
  • Public/Protected
  • All
Menu

blockstack.js 19.4.0-beta.1 Library Reference

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

AmountType

AmountTypeV1

AmountTypeV1: number

AmountTypeV2

AmountTypeV2: object

Type declaration

  • amount: BN
  • units: string

AuthMetadata

AuthMetadata: object

Type declaration

  • Optional email?: string
  • Optional profileUrl?: string

txPoint

txPoint: object

Type declaration

  • script: object
    • length: number

Variables

Const APPS_NODE_INDEX

APPS_NODE_INDEX: 0 = 0

Const AUTH_CONTINUATION_PARAM

AUTH_CONTINUATION_PARAM: "authContinuation" = "authContinuation"

Const BITCOIN_ACCOUNT_INDEX

BITCOIN_ACCOUNT_INDEX: 0 = 0

Const BITCOIN_BIP_44_PURPOSE

BITCOIN_BIP_44_PURPOSE: 44 = 44

Const BITCOIN_COIN_TYPE

BITCOIN_COIN_TYPE: 0 = 0

Const BLOCKSTACK_ON_BITCOIN

BLOCKSTACK_ON_BITCOIN: 0 = 0

Const CHANGE_ADDRESS

CHANGE_ADDRESS: "CHANGE_ADDRESS" = "CHANGE_ADDRESS"

Const DEFAULT_BLOCKSTACK_HOST

DEFAULT_BLOCKSTACK_HOST: "https://browser.blockstack.org/auth" = "https://browser.blockstack.org/auth"

This constant is used in the redirectToSignInWithAuthRequest

Const ECHO_REPLY_PARAM

ECHO_REPLY_PARAM: "echoReply" = "echoReply"

Const EXTERNAL_ADDRESS

EXTERNAL_ADDRESS: "EXTERNAL_ADDRESS" = "EXTERNAL_ADDRESS"

Const GLOBAL_DETECTION_CACHE_KEY

GLOBAL_DETECTION_CACHE_KEY: "_blockstackDidCheckEchoReply" = "_blockstackDidCheckEchoReply"

This logic is in a separate file with no dependencies so that it can be loaded and executed as soon as possible to fulfill the purpose of the protocol detection technique. The effectiveness of this is obviously subject to how web apps bundle/consume the blockstack.js lib.

Const IDENTITY_KEYCHAIN

IDENTITY_KEYCHAIN: 888 = 888

Const SATOSHIS_PER_BTC

SATOSHIS_PER_BTC: 100000000 = 100000000

Const SESSION_VERSION

SESSION_VERSION: "1.0.0" = "1.0.0"

Const SIGNATURE_FILE_SUFFIX

SIGNATURE_FILE_SUFFIX: ".sig" = ".sig"

Const TX_BROADCAST_SERVICE_REGISTRATION_ENDPOINT

TX_BROADCAST_SERVICE_REGISTRATION_ENDPOINT: "registration" = "registration"

Const TX_BROADCAST_SERVICE_TX_ENDPOINT

TX_BROADCAST_SERVICE_TX_ENDPOINT: "transaction" = "transaction"

Const TX_BROADCAST_SERVICE_ZONE_FILE_ENDPOINT

TX_BROADCAST_SERVICE_ZONE_FILE_ENDPOINT: "zone-file" = "zone-file"

Const TX_EMPTY_SIZE

TX_EMPTY_SIZE: number = 4 + 1 + 1 + 4

Const TX_INPUT_BASE

TX_INPUT_BASE: number = 32 + 4 + 1 + 4

Const TX_INPUT_PUBKEYHASH

TX_INPUT_PUBKEYHASH: 107 = 107

Const TX_OUTPUT_BASE

TX_OUTPUT_BASE: number = 8 + 1

Const TX_OUTPUT_PUBKEYHASH

TX_OUTPUT_PUBKEYHASH: 25 = 25

Const VERSION

VERSION: "1.3.1" = "1.3.1"

Const dummyConsensusHash

dummyConsensusHash: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

Const dummyZonefileHash

dummyZonefileHash: "ffffffffffffffffffffffffffffffffffffffff" = "ffffffffffffffffffffffffffffffffffffffff"

Const ecurve

ecurve: ec = new EllipticCurve('secp256k1')

Const intToLevel

intToLevel: object

Type declaration

  • [int: number]: string

Const levelToInt

levelToInt: object

Type declaration

  • [level: string]: number

Const levels

levels: string[] = ['debug','info','warn','error','none']

Functions

decryptContent

  • decryptContent(content: string, options?: object, caller?: UserSession): string | Buffer
  • deprecated

    v19 Use UserSession.decryptContent.

    Decrypts data encrypted with encryptContent with the transit private key.

    Parameters

    • content: string

      encrypted content.

    • Optional options: object
      • Optional privateKey?: string

        the hex string of the ECDSA private key to use for decryption. If not provided, will use user's appPrivateKey.

    • Optional caller: UserSession

    Returns string | Buffer

    decrypted content.

deleteFile

  • deleteFile(path: string, options?: object, caller?: UserSession): Promise<void>
  • Deletes the specified file from the app's data store.

    Parameters

    • path: string

      The path to the file to delete.

    • Optional options: object

      Optional options object.

      • Optional wasSigned?: boolean

        Set to true if the file was originally signed in order for the corresponding signature file to also be deleted.

    • Optional caller: UserSession

    Returns Promise<void>

    Resolves when the file has been removed or rejects with an error.

deleteFromGaiaHub

  • deleteFromGaiaHub(filename: string, hubConfig: GaiaHubConfig): Promise<void>

encryptContent

  • encryptContent(content: string | Buffer, options?: object, caller?: UserSession): string
  • deprecated

    v19 Use UserSession.encryptContent.

    Encrypts the data provided with the app public key.

    Parameters

    • content: string | Buffer

      data to encrypt

    • Optional options: object
      • Optional publicKey?: string

        the hex string of the ECDSA public key to use for encryption. If not provided, will use user's appPublicKey.

    • Optional caller: UserSession

    Returns string

    Stringified ciphertext object

Private estimateAnnounce

  • estimateAnnounce(messageHash: string, senderUtxos?: number): Promise<number>
  • Estimates the cost of an announce transaction

    Parameters

    • messageHash: string

      the hash of the message

    • Default value senderUtxos: number = 1

      the number of utxos we expect will be required from the importer address

    Returns Promise<number>

    • a promise which resolves to the satoshi cost to fund this announce transaction

Private estimateNameImport

  • estimateNameImport(name: string, recipientAddr: string, zonefileHash: string, importUtxos?: number): Promise<number>
  • Estimates the cost of a name-import transaction

    Parameters

    • name: string

      the fully-qualified name

    • recipientAddr: string

      the recipient

    • zonefileHash: string

      the zone file hash

    • Default value importUtxos: number = 1

      the number of UTXOs we expect will be required from the importer address

    Returns Promise<number>

    • a promise which resolves to the satoshi cost to fund this name-import transaction

Private estimateNamespacePreorder

  • estimateNamespacePreorder(namespaceID: string, revealAddress: string, paymentAddress: string, paymentUtxos?: number): Promise<number>
  • Estimates cost of a namespace preorder transaction for a namespace

    Parameters

    • namespaceID: string

      the namespace to preorder

    • revealAddress: string

      the address to receive the namespace (this must be passed as the 'revealAddress' in the namespace-reveal transaction)

    • paymentAddress: string

      the address funding the preorder

    • Default value paymentUtxos: number = 1

      the number of UTXOs we expect will be required from the payment address.

    Returns Promise<number>

    • a promise which resolves to the satoshi cost to fund the preorder. This includes a 5500 satoshi dust output for the preorder. Even though this is a change output, the payer must supply enough funds to generate this output, so we include it in the cost.

Private estimateNamespaceReady

  • estimateNamespaceReady(namespaceID: string, revealUtxos?: number): Promise<number>
  • Estimates the cost of a namespace-ready transaction for a namespace

    Parameters

    • namespaceID: string

      the namespace to ready

    • Default value revealUtxos: number = 1

      the number of UTXOs we expect will be required from the reveal address

    Returns Promise<number>

    • a promise which resolves to the satoshi cost to fund this namespacey-ready transaction.

Private estimateNamespaceReveal

  • estimateNamespaceReveal(namespace: BlockstackNamespace, revealAddress: string, paymentAddress: string, paymentUtxos?: number): Promise<number>
  • Estimates cost of a namesapce reveal transaction for a namespace

    Parameters

    • namespace: BlockstackNamespace

      the namespace to reveal

    • revealAddress: string

      the address to receive the namespace (this must have been passed as 'revealAddress' to a prior namespace preorder)

    • paymentAddress: string

      the address that pays for this transaction

    • Default value paymentUtxos: number = 1

      the number of UTXOs we expect will be required from the payment address

    Returns Promise<number>

    • a promise which resolves to the satoshi cost to fund the reveal. This includes a 5500 satoshi dust output for the preorder. Even though this is a change output, the payer must have enough funds to generate this output, so we include it in the cost.

Private estimatePreorder

  • estimatePreorder(fullyQualifiedName: string, destinationAddress: string, paymentAddress: string, paymentUtxos?: number): Promise<number>
  • Estimates cost of a preorder transaction for a domain name.

    Parameters

    • fullyQualifiedName: string

      the name to preorder

    • destinationAddress: string

      the address to receive the name (this must be passed as the 'registrationAddress' in the register transaction)

    • paymentAddress: string

      the address funding the preorder

    • Default value paymentUtxos: number = 1

      the number of UTXOs we expect will be required from the payment address.

    Returns Promise<number>

    • a promise which resolves to the satoshi cost to fund the preorder. This includes a 5500 satoshi dust output for the preorder. Even though this is a change output, the payer must supply enough funds to generate this output, so we include it in the cost.

Private estimateRegister

  • estimateRegister(fullyQualifiedName: string, registerAddress: string, paymentAddress: string, includingZonefile?: boolean, paymentUtxos?: number): Promise<number>
  • Estimates cost of a register transaction for a domain name.

    Parameters

    • fullyQualifiedName: string

      the name to register

    • registerAddress: string

      the address to receive the name

    • paymentAddress: string

      the address funding the register

    • Default value includingZonefile: boolean = false

      whether or not we will broadcast a zonefile hash as part of the register

    • Default value paymentUtxos: number = 1

      the number of UTXOs we expect will be required from the payment address.

    Returns Promise<number>

    • a promise which resolves to the satoshi cost to fund the register.

Private estimateRenewal

  • estimateRenewal(fullyQualifiedName: string, destinationAddress: string, ownerAddress: string, paymentAddress: string, includingZonefile?: boolean, paymentUtxos?: number): Promise<number>
  • Estimates cost of an transfer transaction for a domain name.

    Parameters

    • fullyQualifiedName: string

      the name to renew

    • destinationAddress: string

      the next owner of the name

    • ownerAddress: string

      the current owner of the name

    • paymentAddress: string

      the address funding the transfer

    • Default value includingZonefile: boolean = false

      whether or not we will broadcast a zonefile hash in the renewal operation

    • Default value paymentUtxos: number = 1

      the number of UTXOs we expect will be required from the payment address.

    Returns Promise<number>

    • a promise which resolves to the satoshi cost to fund the transfer.

Private estimateRevoke

  • estimateRevoke(fullyQualifiedName: string, ownerAddress: string, paymentAddress: string, paymentUtxos?: number): Promise<number>
  • Estimates cost of a revoke transaction for a domain name.

    Parameters

    • fullyQualifiedName: string

      the name to revoke

    • ownerAddress: string

      the current owner of the name

    • paymentAddress: string

      the address funding the revoke

    • Default value paymentUtxos: number = 1

      the number of UTXOs we expect will be required from the payment address.

    Returns Promise<number>

    • a promise which resolves to the satoshi cost to fund the revoke.

Private estimateTokenTransfer

  • estimateTokenTransfer(recipientAddress: string, tokenType: string, tokenAmount: BN, scratchArea: string, senderUtxos?: number, additionalOutputs?: number): Promise<number>
  • Estimates the cost of a token-transfer transaction

    Parameters

    • recipientAddress: string

      the recipient of the tokens

    • tokenType: string

      the type of token to spend

    • tokenAmount: BN

      a 64-bit unsigned BigInteger encoding the number of tokens to spend

    • scratchArea: string

      an arbitrary string to store with the transaction

    • Default value senderUtxos: number = 1

      the number of utxos we expect will be required from the importer address

    • Default value additionalOutputs: number = 1

      the number of outputs we expect to add beyond just the recipient output (default = 1, if the token owner is also the bitcoin funder)

    Returns Promise<number>

    • a promise which resolves to the satoshi cost to fund this token-transfer transaction

Private estimateTransfer

  • estimateTransfer(fullyQualifiedName: string, destinationAddress: string, ownerAddress: string, paymentAddress: string, paymentUtxos?: number): Promise<number>
  • Estimates cost of an transfer transaction for a domain name.

    Parameters

    • fullyQualifiedName: string

      the name to transfer

    • destinationAddress: string

      the next owner of the name

    • ownerAddress: string

      the current owner of the name

    • paymentAddress: string

      the address funding the transfer

    • Default value paymentUtxos: number = 1

      the number of UTXOs we expect will be required from the payment address.

    Returns Promise<number>

    • a promise which resolves to the satoshi cost to fund the transfer.

Private estimateUpdate

  • estimateUpdate(fullyQualifiedName: string, ownerAddress: string, paymentAddress: string, paymentUtxos?: number): Promise<number>
  • Estimates cost of an update transaction for a domain name.

    Parameters

    • fullyQualifiedName: string

      the name to update

    • ownerAddress: string

      the owner of the name

    • paymentAddress: string

      the address funding the update

    • Default value paymentUtxos: number = 1

      the number of UTXOs we expect will be required from the payment address.

    Returns Promise<number>

    • a promise which resolves to the satoshi cost to fund the update.

extractProfile

  • extractProfile(token: string, publicKeyOrAddress?: string | null): object
  • Extracts a profile from an encoded token and optionally verifies it, if publicKeyOrAddress is provided.

    throws

    {Error} - if the token isn't signed by the provided publicKeyOrAddress

    Parameters

    • token: string

      the token to be extracted

    • Default value publicKeyOrAddress: string | null = null

      the public key or address of the keypair that is thought to have signed the token

    Returns object

    • the profile extracted from the encoded token

getAPIUsageErrorMessage

  • getAPIUsageErrorMessage(scopeObject: unknown, apiName: string, usageDesc?: string): string
  • Parameters

    • scopeObject: unknown
    • apiName: string
    • Optional usageDesc: string

    Returns string

getAppBucketUrl

  • getAppBucketUrl(gaiaHubUrl: string, appPrivateKey: string): Promise<string>
  • Get the app storage bucket URL

    Parameters

    • gaiaHubUrl: string

      the gaia hub URL

    • appPrivateKey: string

      the app private key used to generate the app address

    Returns Promise<string>

    That resolves to the URL of the app index file or rejects if it fails

getAuthResponseToken

  • getAuthResponseToken(): string

getFile

  • Retrieves the specified file from the app's data store.

    Parameters

    Returns Promise<string | ArrayBuffer>

    that resolves to the raw data in the file or rejects with an error

getFileContents

  • getFileContents(path: string, app: string, username: string | undefined, zoneFileLookupURL: string | undefined, forceText: boolean, caller?: UserSession): Promise<string | ArrayBuffer | null>
  • Parameters

    • path: string
    • app: string
    • username: string | undefined
    • zoneFileLookupURL: string | undefined
    • forceText: boolean
    • Optional caller: UserSession

    Returns Promise<string | ArrayBuffer | null>

getFileSignedUnencrypted

getFileUrl

getGaiaAddress

  • getGaiaAddress(app: string, username?: string, zoneFileLookupURL?: string, caller?: UserSession): Promise<string>
  • Parameters

    • app: string
    • Optional username: string
    • Optional zoneFileLookupURL: string
    • Optional caller: UserSession

    Returns Promise<string>

getGlobalScope

  • getGlobalScope(): Window

getName

  • getName(profile: any): any

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).

    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

getTransaction

  • getTransaction(txIn: Transaction | TransactionBuilder): Transaction

getUserAppFileUrl

  • getUserAppFileUrl(path: string, username: string, appOrigin: string, zoneFileLookupURL?: string): Promise<string | null>
  • Fetch the public read URL of a user file for the specified app.

    Parameters

    • path: string

      the path to the file to read

    • username: string

      The Blockstack ID of the user to look up

    • appOrigin: string

      The app origin

    • Optional zoneFileLookupURL: string

    Returns Promise<string | null>

    that resolves to the public read URL of the file or rejects with an error

handlePendingSignIn

  • handlePendingSignIn(nameLookupURL?: string, authResponseToken?: string, transitKey?: string, caller?: UserSession): Promise<UserData>
  • deprecated

    v19 Use UserSession.handlePendingSignIn instead.

    Try to process any pending sign in request by returning a Promise that resolves to the user data object if the sign in succeeds.

    Parameters

    • Default value nameLookupURL: string = ""

      the endpoint against which to verify public keys match claimed username

    • Default value authResponseToken: string = getAuthResponseToken()

      the signed authentication response token

    • Optional transitKey: string

      the transit private key that corresponds to the transit public key that was provided in the authentication request

    • Optional caller: UserSession

    Returns Promise<UserData>

    that resolves to the user data object if successful and rejects if handling the sign in request fails or there was no pending sign in request.

handleSignedEncryptedContents

  • handleSignedEncryptedContents(caller: UserSession, path: string, storedContents: string, app: string, username?: string, zoneFileLookupURL?: string): Promise<string | Buffer>
  • Parameters

    • caller: UserSession
    • path: string
    • storedContents: string
    • app: string
    • Optional username: string
    • Optional zoneFileLookupURL: string

    Returns Promise<string | Buffer>

inputBytes

  • inputBytes(input: txPoint | null): number

isSignInPending

  • isSignInPending(): boolean
  • deprecated

    v19 Use UserSession.isSignInPending instead.

    Check if there is a authentication request that hasn't been handled.

    Also checks for a protocol echo reply (which if detected then the page will be automatically redirected after this call).

    Returns boolean

    true if there is a pending sign in, otherwise false

isUserSignedIn

  • isUserSignedIn(): boolean

launchCustomProtocol

  • launchCustomProtocol(authRequest: string, successCallback: function, failCallback: function): void
  • Detects if the native auth-browser is installed and is successfully launched via a custom protocol URI.

    Parameters

    • authRequest: string

      The encoded authRequest to be used as a query param in the custom URI.

    • successCallback: function

      The callback that is invoked when the protocol handler was detected.

        • (): void
        • Returns void

    • failCallback: function

      The callback that is invoked when the protocol handler was not detected.

        • (): void
        • Returns void

    Returns void

listFiles

  • listFiles(callback: function, caller?: UserSession): Promise<number>
  • List the set of files in this application's Gaia storage bucket.

    Parameters

    • callback: function

      a callback to invoke on each named file that returns true to continue the listing operation or false to end it

        • (name: string): boolean
        • Parameters

          • name: string

          Returns boolean

    • Optional caller: UserSession

    Returns Promise<number>

    that resolves to the number of files listed

loadUserData

lookupProfile

  • lookupProfile(username: string, zoneFileLookupURL?: string): Promise<any>
  • Look up a user profile by blockstack ID

    Parameters

    • username: string

      The Blockstack ID of the profile to look up

    • Optional zoneFileLookupURL: string

    Returns Promise<any>

    that resolves to a profile object

Private makeAnnounce

  • makeAnnounce(messageHash: string, senderKeyIn: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>
  • Generates an announce transaction

    Parameters

    • messageHash: string

      the hash of the message to send. Should be an already-announced zone file hash

    • senderKeyIn: string | TransactionSigner

      the private key that pays for the transaction. Should be the key that owns the name that the message recipients subscribe to

    • Default value buildIncomplete: boolean = false

      optional boolean, defaults to false, indicating whether the function should attempt to return an unsigned (or not fully signed) transaction. Useful for passing around a TX for multi-sig input signing.

    Returns Promise<string>

    • a promise which resolves to the hex-encoded transaction. this function does not perform the requisite safety checks -- please see the safety module for those.

makeAuthRequest

  • makeAuthRequest(transitPrivateKey?: string, redirectURI?: string, manifestURI?: string, scopes?: Array<AuthScope | string>, appDomain?: string, expiresAt?: number, extraParams?: any): string
  • Generates an authentication request that can be sent to the Blockstack browser for the user to approve sign in. This authentication request can then be used for sign in by passing it to the redirectToSignInWithAuthRequest method.

    Note: This method should only be used if you want to roll your own authentication flow. Typically you'd use redirectToSignIn which takes care of this under the hood.

    Parameters

    • Optional transitPrivateKey: string

      hex encoded transit private key

    • Optional redirectURI: string

      location to redirect user to after sign in approval

    • Optional manifestURI: string

      location of this app's manifest file

    • Default value scopes: Array<AuthScope | string> = DEFAULT_SCOPE.slice()

      the permissions this app is requesting

    • Optional appDomain: string

      the origin of this app

    • Default value expiresAt: number = nextMonth().getTime()

      the time at which this request is no longer valid

    • Default value extraParams: any = {}

      Any extra parameters you'd like to pass to the authenticator. Use this to pass options that aren't part of the Blockstack auth spec, but might be supported by special authenticators.

    Returns string

    the authentication request

Private makeBitcoinSpend

  • makeBitcoinSpend(destinationAddress: string, paymentKeyIn: string | TransactionSigner, amount: number, buildIncomplete?: boolean): Promise<string>
  • Generates a bitcoin spend to a specified address. This will fund up to amount of satoshis from the payer's UTXOs. It will generate a change output if and only if the amount of leftover change is greater than the additional fees associated with the extra output. If the requested amount is not enough to fund the transaction's associated fees, then this will reject with a InvalidAmountError

    UTXOs are selected largest to smallest, and UTXOs which cannot fund the fees associated with their own input will not be included.

    If you specify an amount > the total balance of the payer address, then this will generate a maximum spend transaction

    Parameters

    • destinationAddress: string

      the address to receive the bitcoin payment

    • paymentKeyIn: string | TransactionSigner

      the private key used to fund the bitcoin spend

    • amount: number

      the amount in satoshis for the payment address to spend in this transaction

    • Default value buildIncomplete: boolean = false

      optional boolean, defaults to false, indicating whether the function should attempt to return an unsigned (or not fully signed) transaction. Useful for passing around a TX for multi-sig input signing.

    Returns Promise<string>

    • a promise which resolves to the hex-encoded transaction.

Private makeNameImport

  • makeNameImport(name: string, recipientAddr: string, zonefileHash: string, importerKeyIn: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>
  • Generates a name import transaction for a namespace

    Parameters

    • name: string

      the name to import

    • recipientAddr: string

      the address to receive the name

    • zonefileHash: string

      the hash of the zonefile to give this name

    • importerKeyIn: string | TransactionSigner

      the private key that pays for the import

    • Default value buildIncomplete: boolean = false

      optional boolean, defaults to false, indicating whether the function should attempt to return an unsigned (or not fully signed) transaction. Useful for passing around a TX for multi-sig input signing.

    Returns Promise<string>

    • a promise which resolves to the hex-encoded transaction. this function does not perform the requisite safety checks -- please see the safety module for those.

Private makeNamespaceReady

  • makeNamespaceReady(namespaceID: string, revealKeyIn: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>
  • Generates a namespace ready transaction for a namespace

    Parameters

    • namespaceID: string

      the namespace to launch

    • revealKeyIn: string | TransactionSigner

      the private key of the 'revealAddress' used to reveal the namespace

    • Default value buildIncomplete: boolean = false

      optional boolean, defaults to false, indicating whether the function should attempt to return an unsigned (or not fully signed) transaction. Useful for passing around a TX for multi-sig input signing.

    Returns Promise<string>

    • a promise which resolves to the hex-encoded transaction. this function does not perform the requisite safety checks -- please see the safety module for those.

Private makeNamespaceReveal

  • makeNamespaceReveal(namespace: BlockstackNamespace, revealAddress: string, paymentKeyIn: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>
  • Generates a namespace reveal transaction for a namespace

    Parameters

    • namespace: BlockstackNamespace

      the namespace to reveal

    • revealAddress: string

      the address to receive the namespace (this must be passed as the 'revealAddress' in the namespace-reveal transaction)

    • paymentKeyIn: string | TransactionSigner

      a hex string (or a TransactionSigner object) of the private key used to fund the transaction

    • Default value buildIncomplete: boolean = false

      optional boolean, defaults to false, indicating whether the function should attempt to return an unsigned (or not fully signed) transaction. Useful for passing around a TX for multi-sig input signing.

    Returns Promise<string>

    • a promise which resolves to the hex-encoded transaction. this function does not perform the requisite safety checks -- please see the safety module for those.

Private makePreorder

  • makePreorder(fullyQualifiedName: string, destinationAddress: string, paymentKeyIn: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>
  • Generates a preorder transaction for a domain name.

    Parameters

    • fullyQualifiedName: string

      the name to pre-order

    • destinationAddress: string

      the address to receive the name (this must be passed as the 'registrationAddress' in the register transaction)

    • paymentKeyIn: string | TransactionSigner

      a hex string of the private key used to fund the transaction or a transaction signer object

    • Default value buildIncomplete: boolean = false

      optional boolean, defaults to false, indicating whether the function should attempt to return an unsigned (or not fully signed) transaction. Useful for passing around a TX for multi-sig input signing.

    Returns Promise<string>

    • a promise which resolves to the hex-encoded transaction. this function does not perform the requisite safety checks -- please see the safety module for those.

Private makeRegister

  • makeRegister(fullyQualifiedName: string, registerAddress: string, paymentKeyIn: string | TransactionSigner, zonefile?: string, valueHash?: string, buildIncomplete?: boolean): Promise<string>
  • Generates a register transaction for a domain name.

    Parameters

    • fullyQualifiedName: string

      the name to register

    • registerAddress: string

      the address to receive the name (this must have been passed as the 'destinationAddress' in the preorder transaction) this address will receive a dust UTXO

    • paymentKeyIn: string | TransactionSigner

      a hex string of the private key (or a TransactionSigner object) used to fund the transaction (this must be the same as the payment address used to fund the preorder)

    • Default value zonefile: string = null

      the zonefile data to include (this will be hashed to include in the transaction), the zonefile itself must be published after the UPDATE propagates.

    • Default value valueHash: string = null

      the hash of the zone file data to include. It will be used instead of zonefile, if given

    • Default value buildIncomplete: boolean = false

      optional boolean, defaults to false, indicating whether the function should attempt to return an unsigned (or not fully signed) transaction. Useful for passing around a TX for multi-sig input signing.

    Returns Promise<string>

    • a promise which resolves to the hex-encoded transaction. this function does not perform the requisite safety checks -- please see the safety module for those.

Private makeRenewal

  • makeRenewal(fullyQualifiedName: string, destinationAddress: string, ownerKeyIn: string | TransactionSigner, paymentKeyIn: string | TransactionSigner, zonefile?: string, valueHash?: string, buildIncomplete?: boolean): Promise<string>
  • Generates a renewal transaction for a domain name.

    Parameters

    • fullyQualifiedName: string

      the name to transfer

    • destinationAddress: string

      the address to receive the name after renewal this address will receive a dust UTXO

    • ownerKeyIn: string | TransactionSigner

      a hex string of the current owner's private key (or a TransactionSigner object)

    • paymentKeyIn: string | TransactionSigner

      a hex string of the private key used to fund the renewal (or a TransactionSigner object)

    • Default value zonefile: string = null

      the zonefile data to include, if given (this will be hashed to include in the transaction), the zonefile itself must be published after the RENEWAL propagates.

    • Default value valueHash: string = null

      the raw zone file hash to include (this will be used instead of zonefile, if given).

    • Default value buildIncomplete: boolean = false

      optional boolean, defaults to false, indicating whether the function should attempt to return an unsigned (or not fully signed) transaction. Useful for passing around a TX for multi-sig input signing.

    Returns Promise<string>

    • a promise which resolves to the hex-encoded transaction. this function does not perform the requisite safety checks -- please see the safety module for those.

Private makeRevoke

  • makeRevoke(fullyQualifiedName: string, ownerKeyIn: string | TransactionSigner, paymentKeyIn: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>
  • Generates a revoke transaction for a domain name.

    Parameters

    • fullyQualifiedName: string

      the name to revoke

    • ownerKeyIn: string | TransactionSigner

      a hex string of the current owner's private key (or a TransactionSigner object)

    • paymentKeyIn: string | TransactionSigner

      a hex string of the private key used to fund the transaction (or a TransactionSigner object)

    • Default value buildIncomplete: boolean = false

      optional boolean, defaults to false, indicating whether the function should attempt to return an unsigned (or not fully signed) transaction. Useful for passing around a TX for multi-sig input signing.

    Returns Promise<string>

    • a promise which resolves to the hex-encoded transaction. this function does not perform the requisite safety checks -- please see the safety module for those.

Private makeTokenTransfer

  • makeTokenTransfer(recipientAddress: string, tokenType: string, tokenAmount: BN, scratchArea: string, senderKeyIn: string | TransactionSigner, btcFunderKeyIn?: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>
  • Generates a token-transfer transaction

    Parameters

    • recipientAddress: string

      the address to receive the tokens

    • tokenType: string

      the type of tokens to send

    • tokenAmount: BN

      the BigInteger encoding of an unsigned 64-bit number of tokens to send

    • scratchArea: string

      an arbitrary string to include with the transaction

    • senderKeyIn: string | TransactionSigner

      the hex-encoded private key to send the tokens

    • Optional btcFunderKeyIn: string | TransactionSigner

      the hex-encoded private key to fund the bitcoin fees for the transaction. Optional -- if not passed, will attempt to fund with sender key.

    • Default value buildIncomplete: boolean = false

      optional boolean, defaults to false, indicating whether the function should attempt to return an unsigned (or not fully signed) transaction. Useful for passing around a TX for multi-sig input signing.

    Returns Promise<string>

    • a promise which resolves to the hex-encoded transaction. This function does not perform the requisite safety checks -- please see the safety module for those.

Private makeTransfer

  • makeTransfer(fullyQualifiedName: string, destinationAddress: string, ownerKeyIn: string | TransactionSigner, paymentKeyIn: string | TransactionSigner, keepZonefile?: boolean, buildIncomplete?: boolean): Promise<string>
  • Generates a transfer transaction for a domain name.

    Parameters

    • fullyQualifiedName: string

      the name to transfer

    • destinationAddress: string

      the address to receive the name. this address will receive a dust UTXO

    • ownerKeyIn: string | TransactionSigner

      a hex string of the current owner's private key (or a TransactionSigner object)

    • paymentKeyIn: string | TransactionSigner

      a hex string of the private key used to fund the transaction (or a TransactionSigner object)

    • Default value keepZonefile: boolean = false

      if true, then preserve the name's zone file

    • Default value buildIncomplete: boolean = false

      optional boolean, defaults to false, indicating whether the function should attempt to return an unsigned (or not fully signed) transaction. Useful for passing around a TX for multi-sig input signing.

    Returns Promise<string>

    • a promise which resolves to the hex-encoded transaction. this function does not perform the requisite safety checks -- please see the safety module for those.

Private makeUpdate

  • makeUpdate(fullyQualifiedName: string, ownerKeyIn: string | TransactionSigner, paymentKeyIn: string | TransactionSigner, zonefile: string, valueHash?: string, buildIncomplete?: boolean): Promise<string>
  • Generates an update transaction for a domain name.

    Parameters

    • fullyQualifiedName: string

      the name to update

    • ownerKeyIn: string | TransactionSigner

      a hex string of the owner key, or a transaction signer object. This will provide one UTXO input, and also recieve a dust output.

    • paymentKeyIn: string | TransactionSigner

      a hex string, or a transaction signer object, of the private key used to fund the transaction's txfees

    • zonefile: string

      the zonefile data to update (this will be hashed to include in the transaction), the zonefile itself must be published after the UPDATE propagates.

    • Default value valueHash: string = ""

      if given, this is the hash to store (instead of zonefile). zonefile will be ignored if this is given.

    • Default value buildIncomplete: boolean = false

      optional boolean, defaults to false, indicating whether the function should attempt to return an unsigned (or not fully signed) transaction. Useful for passing around a TX for multi-sig input signing.

    Returns Promise<string>

    • a promise which resolves to the hex-encoded transaction. this function does not perform the requisite safety checks -- please see the safety module for those.

outputBytes

  • outputBytes(output: txPoint | null): number

putFile

  • Stores the data provided in the app's data store to to the file specified.

    Parameters

    • path: string

      the path to store the data in

    • content: string | Buffer

      the data to store in the file

    • Optional options: PutFileOptions
    • Optional caller: UserSession

    Returns Promise<string>

    that resolves if the operation succeed and rejects if it failed

redirectToSignIn

  • redirectToSignIn(redirectURI?: string, manifestURI?: string, scopes?: Array<AuthScope | string>): void
  • deprecated

    v19 Use UserSession.isUserSignedIn instead.

    Generates an authentication request and redirects the user to the Blockstack browser to approve the sign in request.

    Please note that this requires that the web browser properly handles the blockstack: URL protocol handler.

    Most applications should use this method for sign in unless they require more fine grained control over how the authentication request is generated. If your app falls into this category, use makeAuthRequest and redirectToSignInWithAuthRequest to build your own sign in process.

    Parameters

    • Optional redirectURI: string
    • Optional manifestURI: string
    • Optional scopes: Array<AuthScope | string>

    Returns void

redirectToSignInWithAuthRequest

  • redirectToSignInWithAuthRequest(authRequest?: string, blockstackIDHost?: string): void
  • deprecated

    v19 Use UserSession.redirectToSignInWithAuthRequest instead.

    Redirects the user to the Blockstack browser to approve the sign in request given.

    The user is redirected to the blockstackIDHost if the blockstack: protocol handler is not detected. Please note that the protocol handler detection does not work on all browsers.

    Parameters

    • Optional authRequest: string

      the authentication request generated by makeAuthRequest

    • Default value blockstackIDHost: string = DEFAULT_BLOCKSTACK_HOST

      the URL to redirect the user to if the blockstack protocol handler is not detected

    Returns void

signInputs

  • signInputs(txB: TransactionBuilder, defaultSigner: TransactionSigner, otherSigners?: Array<object>): Promise<TransactionBuilder>
  • Parameters

    • txB: TransactionBuilder
    • defaultSigner: TransactionSigner
    • Optional otherSigners: Array<object>

    Returns Promise<TransactionBuilder>

signProfileToken

  • signProfileToken(profile: any, privateKey: string, subject?: any, issuer?: any, signingAlgorithm?: string, issuedAt?: Date, expiresAt?: Date): string
  • Signs a profile token

    Parameters

    • profile: any

      the JSON of the profile to be signed

    • privateKey: string

      the signing private key

    • Optional subject: any

      the entity that the information is about

    • Optional issuer: any

      the entity that is issuing the token

    • Default value signingAlgorithm: string = "ES256K"

      the signing algorithm to use

    • Default value issuedAt: Date = new Date()

      the time of issuance of the token

    • Default value expiresAt: Date = nextYear()

      the time of expiration of the token

    Returns string

    • the signed profile token

signUserOut

  • signUserOut(redirectURL?: string, caller?: UserSession): void
  • deprecated

    v19 Use UserSession.signUserOut instead.

    Sign the user out and optionally redirect to given location.

    Parameters

    • Optional redirectURL: string

      Location to redirect user to after sign out. Only used in environments with window available

    • Optional caller: UserSession

    Returns void

transactionBytes

  • transactionBytes(inputs: Array<txPoint | null>, outputs: Array<txPoint | null>): number

validateProofs

  • validateProofs(profile: any, ownerAddress: string, name?: string): Promise<any[]>
  • Validates the social proofs in a user's profile. Currently supports validation of Facebook, Twitter, GitHub, Instagram, LinkedIn and HackerNews accounts.

    Parameters

    • profile: any

      The JSON of the profile to be validated

    • ownerAddress: string

      The owner bitcoin address to be validated

    • Default value name: string = null

    Returns Promise<any[]>

    that resolves to an array of validated proof objects

verifyProfileToken

  • verifyProfileToken(token: string, publicKeyOrAddress: string): TokenInterface
  • Verifies a profile token

    throws

    {Error} - throws an error if token verification fails

    Parameters

    • token: string

      the token to be verified

    • publicKeyOrAddress: string

      the public key or address of the keypair that is thought to have signed the token

    Returns TokenInterface

    • the verified, decoded profile token

wrapProfileToken

  • wrapProfileToken(token: string): object
  • Wraps a token for a profile token file

    Parameters

    • token: string

      the token to be wrapped

    Returns object

    • including token and decodedToken
    • decodedToken: TokenInterface
    • token: string

Object literals

Const DEFAULT_PROFILE

DEFAULT_PROFILE: object

@context

@context: string = "http://schema.org"

@type

@type: string = "Person"

Const schemaDefinition

schemaDefinition: object

strict

strict: boolean = false

type

type: string = "object"

properties

properties: object

@context

@context: object

optional

optional: boolean = true

type

type: string = "string"

@id

@id: object

optional

optional: boolean = true

type

type: string = "string"

@type

@type: object

type

type: string = "string"

account

account: object

optional

optional: boolean = true

type

type: string = "array"

items

items: object

type

type: string = "object"

properties

properties: object

@type

@type: object

type

type: string = "string"

identifier

identifier: object

optional

optional: boolean = true

type

type: string = "string"

proofMessage

proofMessage: object

optional

optional: boolean = true

type

type: string = "string"

proofSignature

proofSignature: object

optional

optional: boolean = true

type

type: string = "string"

proofType

proofType: object

optional

optional: boolean = true

type

type: string = "string"

proofUrl

proofUrl: object

optional

optional: boolean = true

type

type: string = "string"

service

service: object

optional

optional: boolean = true

type

type: string = "string"

address

address: object

optional

optional: boolean = true

type

type: string = "object"

properties

properties: object

@type

@type: object

type

type: string = "string"

addressCountry

addressCountry: object

optional

optional: boolean = true

type

type: string = "string"

addressLocality

addressLocality: object

optional

optional: boolean = true

type

type: string = "string"

postalCode

postalCode: object

optional

optional: boolean = true

type

type: string = "string"

streetAddress

streetAddress: object

optional

optional: boolean = true

type

type: string = "string"

birthDate

birthDate: object

optional

optional: boolean = true

type

type: string = "string"

description

description: object

optional

optional: boolean = true

type

type: string = "string"

familyName

familyName: object

optional

optional: boolean = true

type

type: string = "string"

givenName

givenName: object

optional

optional: boolean = true

type

type: string = "string"

image

image: object

optional

optional: boolean = true

type

type: string = "array"

items

items: object

type

type: string = "object"

properties

properties: object

@type

@type: object

type

type: string = "string"

contentUrl

contentUrl: object

optional

optional: boolean = true

type

type: string = "string"

name

name: object

optional

optional: boolean = true

type

type: string = "string"

knows

knows: object

optional

optional: boolean = true

type

type: string = "array"

items

items: object

type

type: string = "object"

properties

properties: object

@id

@id: object

optional

optional: boolean = true

type

type: string = "string"

@type

@type: object

type

type: string = "string"

name

name: object

optional

optional: boolean = true

type

type: string = "string"

taxID

taxID: object

optional

optional: boolean = true

type

type: string = "string"

website

website: object

optional

optional: boolean = true

type

type: string = "array"

items

items: object

type

type: string = "object"

properties

properties: object

@type

@type: object

type

type: string = "string"

url

url: object

optional

optional: boolean = true

type

type: string = "string"

worksFor

worksFor: object

optional

optional: boolean = true

type

type: string = "array"

items

items: object

type

type: string = "object"

properties

properties: object

@id

@id: object

optional

optional: boolean = true

type

type: string = "string"

@type

@type: object

type

type: string = "string"

Const transactions

transactions: object

BlockstackNamespace

BlockstackNamespace: BlockstackNamespace

estimateAnnounce

estimateAnnounce: estimateAnnounce

estimateNameImport

estimateNameImport: estimateNameImport

estimateNamespacePreorder

estimateNamespacePreorder: estimateNamespacePreorder

estimateNamespaceReady

estimateNamespaceReady: estimateNamespaceReady

estimateNamespaceReveal

estimateNamespaceReveal: estimateNamespaceReveal

estimatePreorder

estimatePreorder: estimatePreorder

estimateRegister

estimateRegister: estimateRegister

estimateRenewal

estimateRenewal: estimateRenewal

estimateRevoke

estimateRevoke: estimateRevoke

estimateTokenTransfer

estimateTokenTransfer: estimateTokenTransfer

estimateTransfer

estimateTransfer: estimateTransfer

estimateUpdate

estimateUpdate: estimateUpdate

makeAnnounce

makeAnnounce: makeAnnounce

makeBitcoinSpend

makeBitcoinSpend: makeBitcoinSpend

makeNameImport

makeNameImport: makeNameImport

makeNamespacePreorder

makeNamespacePreorder: makeNamespacePreorder

makeNamespaceReady

makeNamespaceReady: makeNamespaceReady

makeNamespaceReveal

makeNamespaceReveal: makeNamespaceReveal

makePreorder

makePreorder: makePreorder

makeRegister

makeRegister: makeRegister

makeRenewal

makeRenewal: makeRenewal

makeRevoke

makeRevoke: makeRevoke

makeTokenTransfer

makeTokenTransfer: makeTokenTransfer

makeTransfer

makeTransfer: makeTransfer

makeUpdate

makeUpdate: makeUpdate

Generated using TypeDoc