Constructor
new Brambl(params)
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
string
|
Constructor parameters object
|
Requires:
- module:Requests
- module:KeyManager
Members
Methods
(static) Hash(type, msg, encoding) → {object}
Method for accessing the hash utility as a static method
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
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
constructor object for key manager or as a string password
|
Returns:
- Type:
-
object
new KeyManager instance
(static) Requests(networkPrefixopt, urlopt, apiKeyopt) → {object}
Method for creating a separate Requests instance
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
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.
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.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
txId |
string
|
The unique transaction ID to look for | |||||||||||||||||
options |
object
|
<optional> |
Optional parameters to control the polling behavior
|
Returns:
- Type:
-
promise
pollTx - polling promise
signAndBroadcast(prototypeTx) → {promise}
Used to sign a prototype transaction and broadcast to a chain provider
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
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