Brambl

Brambl

Creates an instance of Brambl for interacting with the Topl protocol

Constructor

new Brambl(params)

Source:
Parameters:
Name Type Description
params object | string Constructor parameters object
Name Type Description
networkPrefix string Network Prefix
password string The password used to encrpt the keyfile, same as [params.KeyManager.password]
KeyManager object KeyManager object (may be either an instance or config parameters)
Name Type Attributes Description
password string <optional>
The password used to encrpt the keyfile
keyPath string <optional>
Path to a keyfile
keyFile object <optional>
encrypted keyFile javascript object.
constants string <optional>
Parameters for encrypting the user's keyfile
Requests object Request object (may be either an instance or config parameters)
Name Type Attributes Description
url string <optional>
The chain provider to send requests to
apikey string <optional>
Api key for authorizing access to the chain provider
Requires:
  • module:Requests
  • module:KeyManager

Members

networkPrefix

Getter for private property #networkPrefix
Source:

networkPrefix

Setter for private property #isLocked
Source:

Methods

(static) Hash(type, msg, encoding) → {object}

Method for accessing the hash utility as a static method
Source:
Parameters:
Name Type Default Description
type string type of hash to construct
msg object | string the msg that will be hashed
encoding object | string base58 optional, default is "base58"
Returns:
Type:
object
Hash Instance

(static) KeyManager(params) → {object}

Method for creating a separate KeyManager instance
Source:
Parameters:
Name Type Description
params object constructor object for key manager or as a string password
Name Type Attributes Description
password string <optional>
password for encrypting (decrypting) the keyfile
keyPath string <optional>
path to import keyfile
keyFile object <optional>
encrypted keyFile javascript object.
constants object <optional>
default encryption options for storing keyfiles
networkPrefix string <optional>
Network Prefix, defaults to "private"
Returns:
Type:
object
new KeyManager instance

(static) Requests(networkPrefixopt, urlopt, apiKeyopt) → {object}

Method for creating a separate Requests instance
Source:
Parameters:
Name Type Attributes Default Description
networkPrefix string <optional>
"private" Network Prefix, defaults to "private"
url string <optional>
"http://localhost:9085/" Chain provider location
apiKey string <optional>
"topl_the_world!" Access key for authorizing requests to the client API
Returns:
Type:
object
new Requests instance

addSigToTx(prototypeTx, userKeys) → {object}

Add a signature to a prototype transaction using an unlocked key manager object
Source:
Parameters:
Name Type Description
prototypeTx object An unsigned transaction JSON object
userKeys object | Array.<object> A keyManager object containing the user's key (may be an array)
Returns:
Type:
object
transaction with signatures to all given key files

createAssetCode(shortName) → {string}

A function to create an Asset Code by utilizing the Key created or imported by Brambl. Asset Codes are necessary to create Raw Asset transactions.
Source:
Parameters:
Name Type Description
shortName string name of assets, up to 8 bytes long latin-1 enconding
Returns:
Type:
string
asset code is returned if successful

pollTx(txId, optionsopt) → {promise}

A function to initiate polling of the chain provider for a specified transaction. This function begins by querying 'getTransactionById' which looks for confirmed transactions only. If the transaction is not confirmed, the mempool is checked using 'getTransactionFromMemPool' to ensure that the transaction is pending. The parameter 'numFailedQueries' specifies the number of consecutive failures (when resorting to querying the mempool) before ending the polling operation prematurely.
Source:
Parameters:
Name Type Attributes Description
txId string The unique transaction ID to look for
options object <optional>
Optional parameters to control the polling behavior
Name Type Attributes Description
timeout number <optional>
The timeout (in seconds) before the polling operation is stopped
interval number <optional>
The interval (in seconds) between attempts
maxFailedQueries number <optional>
The maximum number of consecutive failures (to find the unconfirmed transaction) before ending the poll execution
Returns:
Type:
promise
pollTx - polling promise

signAndBroadcast(prototypeTx) → {promise}

Used to sign a prototype transaction and broadcast to a chain provider
Source:
Parameters:
Name Type Description
prototypeTx object An unsigned transaction JSON object
Returns:
Type:
promise
requests.broadcastTx promise

transaction(method, params) → {promise}

Create a new transaction, then sign and broadcast
Source:
Parameters:
Name Type Description
method string The chain resource method to create a transaction for. Valid transaction methods are the following: "createRawArbitTransfer", "createRawAssetTransfer", "createRawPolyTransfer".
params object Transaction parameters object
Returns:
Type:
promise
signAndBroadcast promise