Requests

Requests

A class for sending requests to the Brambl layer interface of the given chain provider

Constructor

new Requests()

Source:

Methods

(async) broadcastTx(params, idopt) → {object}

Broadcast a valid signed transaction that will be gossiped about to other nodes
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Description
tx string a JSON formatted transaction (must include signature(s))
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) createRawArbitTransfer(params, idopt) → {object}

Create a raw transaction for transferring arbits between addresses
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Attributes Description
propositionType string Proposition Type -> PublicKeyCurve25519 || TheresholdCurve25519
recipients string 2-dimensional array (array of tuples) -> [["publicKey of asset recipient", quantity]]
sender array List of senders addresses
changeAddress string Address of the change recipient
consolidationAddress string Address of the change recipient
fee number Fee to apply to the transaction
data string <optional>
Data string which can be associated with this transaction (may be empty). Must be less than or equal to 127 Latin-1 encoded characters.
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) createRawAssetTransfer(params, idopt) → {object}

Create a new asset on chain
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Attributes Description
propositionType string Proposition Type -> PublicKeyCurve25519 || TheresholdCurve25519
recipients string 2-dimensional array (array of tuples) -> [["address of recipient", quantity, securityRoot, metadata]]
recipients[i][0]: string Required address of recipient
recipients[i][1]: string Required number of tokens to send to recipient
recipients[i][2]: string Optional security root which is a Base58 encoded 32 byte hash of the data to be stored in the AssetBox.
recipients[i][3]: string Optional metadata tag for asset, must be less than 128 Latin-1 characters.
assetCode string Identifier of the asset
sender string Public key of the asset issuer
changeAddress string Public key of the change recipient
minting boolean Minting boolean
fee number Fee to apply to the transaction
consolidationAddress string Address for recipient of unspent Assets
data string <optional>
Data string which can be associated with this transaction (may be empty). Must be less than or equal to 127 Latin-1 encoded characters.
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) createRawPolyTransfer(params, idopt) → {object}

Create a raw transaction for transferring polys between addresses
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Attributes Description
propositionType string Proposition Type -> PublicKeyCurve25519 || TheresholdCurve25519
recipients string 2-dimensional array (array of tuples) -> [["publicKey of asset recipient", quantity]]
sender array List of senders addresses
changeAddress string Address of the change recipient
fee number Fee to apply to the transaction
data string <optional>
Data string which can be associated with this transaction (may be empty). This field is restricted to 127 Latin-1 encoded characters
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) getBlockByHeight(params, idopt) → {object}

Lookup a block from history by the provided id
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Description
height number Height as an integer number
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) getBlockById(params, idopt) → {object}

Lookup a block from history by the provided id
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Description
blockId string Unique identifier of the block to retrieve
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) getLatestBlock(idopt) → {object}

Return the latest block in the chain
Source:
Parameters:
Name Type Attributes Default Description
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) getMempool(idopt) → {object}

Return the entire mempool of the node
Source:
Parameters:
Name Type Attributes Default Description
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) getTransactionById(params, idopt) → {object}

Lookup a transaction from history by the provided id
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Description
transactionId string Unique identifier of the transaction to retrieve
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) getTransactionFromMempool(params, idopt) → {object}

Lookup a transaction from the mempool by the provided id
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Description
transactionId string Unique identifier of the transaction to retrieve
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) lookupBalancesByAddresses(params, idopt) → {object}

Lookup the balances of specified addresses
Source:
Parameters:
Name Type Attributes Default Description
params Object body parameters passed to the specified json-rpc method
Name Type Description
addresses Array.<string> An array of addresses to query the balance for
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

setApiKey(apiKey) → {void}

Allows setting a different x-api-key than the default
Source:
Parameters:
Name Type Description
apiKey string api-key for "x-api-key"
Returns:
Type:
void

setUrl(url) → {void}

Allows setting a different url than the default from which to create and accept RPC connections
Source:
Parameters:
Name Type Description
url string url string for instance
Returns:
Type:
void

Requests

new Requests(networkPrefixopt, urlopt, apiKeyopt)

Source:
Parameters:
Name Type Attributes Default Description
networkPrefix string <optional>
"private" Network Prefix, defaults to "private"
url string <optional>
"http://localhost:9085/YOUR_PROJECT_ID" Chain provider location, local and private default to http://localhost:9085/
apiKey string <optional>
"topl_the_world!" Access key for authorizing requests to the client API ["x-api-key"], default to "topl_the_world!"

Methods

(async) broadcastTx(params, idopt) → {object}

Broadcast a valid signed transaction that will be gossiped about to other nodes
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Description
tx string a JSON formatted transaction (must include signature(s))
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) createRawArbitTransfer(params, idopt) → {object}

Create a raw transaction for transferring arbits between addresses
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Attributes Description
propositionType string Proposition Type -> PublicKeyCurve25519 || TheresholdCurve25519
recipients string 2-dimensional array (array of tuples) -> [["publicKey of asset recipient", quantity]]
sender array List of senders addresses
changeAddress string Address of the change recipient
consolidationAddress string Address of the change recipient
fee number Fee to apply to the transaction
data string <optional>
Data string which can be associated with this transaction (may be empty). Must be less than or equal to 127 Latin-1 encoded characters.
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) createRawAssetTransfer(params, idopt) → {object}

Create a new asset on chain
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Attributes Description
propositionType string Proposition Type -> PublicKeyCurve25519 || TheresholdCurve25519
recipients string 2-dimensional array (array of tuples) -> [["address of recipient", quantity, securityRoot, metadata]]
recipients[i][0]: string Required address of recipient
recipients[i][1]: string Required number of tokens to send to recipient
recipients[i][2]: string Optional security root which is a Base58 encoded 32 byte hash of the data to be stored in the AssetBox.
recipients[i][3]: string Optional metadata tag for asset, must be less than 128 Latin-1 characters.
assetCode string Identifier of the asset
sender string Public key of the asset issuer
changeAddress string Public key of the change recipient
minting boolean Minting boolean
fee number Fee to apply to the transaction
consolidationAddress string Address for recipient of unspent Assets
data string <optional>
Data string which can be associated with this transaction (may be empty). Must be less than or equal to 127 Latin-1 encoded characters.
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) createRawPolyTransfer(params, idopt) → {object}

Create a raw transaction for transferring polys between addresses
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Attributes Description
propositionType string Proposition Type -> PublicKeyCurve25519 || TheresholdCurve25519
recipients string 2-dimensional array (array of tuples) -> [["publicKey of asset recipient", quantity]]
sender array List of senders addresses
changeAddress string Address of the change recipient
fee number Fee to apply to the transaction
data string <optional>
Data string which can be associated with this transaction (may be empty). This field is restricted to 127 Latin-1 encoded characters
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) getBlockByHeight(params, idopt) → {object}

Lookup a block from history by the provided id
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Description
height number Height as an integer number
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) getBlockById(params, idopt) → {object}

Lookup a block from history by the provided id
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Description
blockId string Unique identifier of the block to retrieve
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) getLatestBlock(idopt) → {object}

Return the latest block in the chain
Source:
Parameters:
Name Type Attributes Default Description
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) getMempool(idopt) → {object}

Return the entire mempool of the node
Source:
Parameters:
Name Type Attributes Default Description
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) getTransactionById(params, idopt) → {object}

Lookup a transaction from history by the provided id
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Description
transactionId string Unique identifier of the transaction to retrieve
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) getTransactionFromMempool(params, idopt) → {object}

Lookup a transaction from the mempool by the provided id
Source:
Parameters:
Name Type Attributes Default Description
params object body parameters passed to the specified json-rpc method
Name Type Description
transactionId string Unique identifier of the transaction to retrieve
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

(async) lookupBalancesByAddresses(params, idopt) → {object}

Lookup the balances of specified addresses
Source:
Parameters:
Name Type Attributes Default Description
params Object body parameters passed to the specified json-rpc method
Name Type Description
addresses Array.<string> An array of addresses to query the balance for
id string <optional>
"1" identifying number for the json-rpc request
Returns:
Type:
object
json-rpc response from the chain

setApiKey(apiKey) → {void}

Allows setting a different x-api-key than the default
Source:
Parameters:
Name Type Description
apiKey string api-key for "x-api-key"
Returns:
Type:
void

setUrl(url) → {void}

Allows setting a different url than the default from which to create and accept RPC connections
Source:
Parameters:
Name Type Description
url string url string for instance
Returns:
Type:
void