@burstjs/core
Burst-related functions and models for building Burstcoin applications.
Installation
Install using npm:
npm install @burstjs/core
or using yarn:
yarn add @burstjs/core
API Reference
Classes
- BurstService
Generic BRS Web Service class.
Extend and specific services here
Functions
- generateSendTransactionQRCode(receiverId, amountNQT, feeSuggestionType) ⇒
Promise.<ArrayBufferLike>
Get QR Code image for a given BURST address
- generateSendTransactionQRCodeAddress(receiverId, amountNQT, feeSuggestionType) ⇒
Promise.<string>
Generate the URL for a QR Code for a given BURST address. Useful for IMG tags in HTML.
- getAccountBalance()
Submits a getBalance query given an accountId
- getAccountTransactions(accountId, firstIndex, lastIndex, numberOfConfirmations) ⇒
Promise.<TransactionList>
Get transactions of given account
- getAliases(accountId) ⇒
Promise.<AliasList>
Gets the aliases of an account
- getUnconfirmedAccountTransactions(accountId) ⇒
Promise.<UnconfirmedTransactionList>
Get unconfirmed transactions of given account
- getBlockByHeight(height, includeTransactions) ⇒
Get a block by given height
- getBlockById(id, includeTransactions) ⇒
Get a block by given id
- getBlockByTimestamp()
Original work Copyright (c) 2019 Burst Apps Team
- getBlockId(height) ⇒
Promise.<BlockId>
Get a block id by given height
- constructAttachment(transactions, params) ⇒
Constructs an Attachment
- sendTextMessage(message, recipientId, senderPublicKey, senderPrivateKey, fee) ⇒
Broadcasts a text message to the network/blockchain
The message will be broadcasted in two steps.
- Send the message with public key to the network
- Take the returned unsigned message and sign it, i.e. the private key won't be transmitted.
- getBlockchainStatus() ⇒
Get the blockchain status.
- getServerStatus() ⇒
Get the state of the server node and network
- suggestFee() ⇒
Promise.<SuggestedFees>
Get the current suggested fees
- broadcastTransaction(signedTransactionPayload) ⇒
Broadcasts a transaction to the network/blockchain
- getTransaction(transactionId) ⇒
Get a transaction from the network/blockchain
- sendMoney(transaction, senderPublicKey, senderPrivateKey, recipientAddress) ⇒
Sends burst to the blockchain
The message will be broadcasted in two steps.
- Send the sendMoney call with public key to the network
- Take the returned unsigned message and sign it, i.e. the private key won't be transmitted.
BurstService
Generic BRS Web Service class.
Extend and specific services here
Kind: global class
new BurstService(baseUrl, relativePath, httpClient)
Creates Service instance
Param | Type | Description |
---|
baseUrl | | The host url of web service |
relativePath | | The relative path will be prepended before each url created with toBRSEndpoint() |
httpClient | Http | If passed an client instance, it will be used instead of default HttpImpl. Good for testing. |
burstService.http ⇒
Kind: instance property of BurstService
Returns:
The internal Http client
burstService.toBRSEndpoint(method, data) ⇒
Mounts a BRS conform API endpoint of format <host>?requestType=getBlock&height=123
Kind: instance method of BurstService
Returns:
The mounted url (without host)
See:
https://burstwiki.org/wiki/The_Burst_API
Param | Description |
---|
method | The method name for requestType |
data | A JSON object which will be mapped to url params |
burstService.query(method, args) ⇒
Requests a query to BRS
Kind: instance method of BurstService
Returns:
The response data of success
Throws:
burstService.send(method, args, body) ⇒
Send data to BRS
Kind: instance method of BurstService
Returns:
The response data of success
Throws:
Param | Description |
---|
method | The BRS method accordinghttps://burstwiki.org/wiki/The_Burst_API#Create_Transaction. Note that there are only a few POST methods |
args | A JSON object which will be mapped to url params |
body | An object with key value pairs to submit as post body |
generateSendTransactionQRCode(receiverId, amountNQT, feeSuggestionType) ⇒ Promise.<ArrayBufferLike>
Get QR Code image for a given BURST address
Kind: global function
Param | Type | Description |
---|
receiverId | string | The recipient burst |
amountNQT | string | The amount (in NQT) to request |
feeSuggestionType | string | The fee suggestion type string |
generateSendTransactionQRCodeAddress(receiverId, amountNQT, feeSuggestionType) ⇒ Promise.<string>
Generate the URL for a QR Code for a given BURST address. Useful for IMG tags in HTML.
Kind: global function
Param | Type | Description |
---|
receiverId | string | The recipient burst address |
amountNQT | string | The amount (in NQT) to request |
feeSuggestionType | string | The fee suggestion type string |
getAccountBalance()
Submits a getBalance query given an accountId
Kind: global function
getAccountTransactions(accountId, firstIndex, lastIndex, numberOfConfirmations) ⇒ Promise.<TransactionList>
Get transactions of given account
Kind: global function
Param | Type | Description |
---|
accountId | string | The numeric accountId |
firstIndex | number | The first index of the transaction list, beginning at 0 |
lastIndex | number | The last index of the transaction list |
numberOfConfirmations | number | The minimum required number of confirmations per transaction |
getAliases(accountId) ⇒ Promise.<AliasList>
Gets the aliases of an account
Kind: global function
getUnconfirmedAccountTransactions(accountId) ⇒ Promise.<UnconfirmedTransactionList>
Get unconfirmed transactions of given account
Kind: global function
Param | Type | Description |
---|
accountId | string | The numeric accountId |
getBlockByHeight(height, includeTransactions) ⇒
Get a block by given height
Kind: global function
Returns:
The Block
Param | Description |
---|
height | The block height |
includeTransactions | true, if transactions shall be included |
getBlockById(id, includeTransactions) ⇒
Get a block by given id
Kind: global function
Returns:
The Block
Param | Description |
---|
id | The block id |
includeTransactions | true, if transactions shall be included |
getBlockByTimestamp()
Original work Copyright (c) 2019 Burst Apps Team
Kind: global function
getBlockId(height) ⇒ Promise.<BlockId>
Get a block id by given height
Kind: global function
Returns: Promise.<BlockId>
-
The Block Id
Param | Type | Description |
---|
height | number | The block height |
constructAttachment(transactions, params) ⇒
Constructs an Attachment
Kind: global function
Returns:
HttpParams
Param | Description |
---|
transactions | The transaction with the attachment |
params | Some HttpParams |
sendTextMessage(message, recipientId, senderPublicKey, senderPrivateKey, fee) ⇒
Broadcasts a text message to the network/blockchain
The message will be broadcasted in two steps.
- Send the message with public key to the network
- Take the returned unsigned message and sign it, i.e. the private key won't be transmitted.
Kind: global function
Returns:
The Transaction Id
Param | Description |
---|
message | The text message to be sent |
recipientId | The recipients Id, not RS Address |
senderPublicKey | The senders public key for sending an unsigned message |
senderPrivateKey | The senders private key to sign the message |
fee | The optional fee (expressed in Burst) for the message, default is 0.1 Burst. |
getBlockchainStatus() ⇒
Get the blockchain status.
Kind: global function
Returns:
The Blockchain Status
getServerStatus() ⇒
Get the state of the server node and network
Kind: global function
Returns:
The server Status
suggestFee() ⇒ Promise.<SuggestedFees>
Get the current suggested fees
Kind: global function
Returns: Promise.<SuggestedFees>
-
The Suggested Fees
broadcastTransaction(signedTransactionPayload) ⇒
Broadcasts a transaction to the network/blockchain
Kind: global function
Returns:
The Transaction Id
Param | Description |
---|
signedTransactionPayload | The signed transaction payload encoded in base64 |
getTransaction(transactionId) ⇒
Get a transaction from the network/blockchain
Kind: global function
Returns:
The Transaction
Param | Description |
---|
transactionId | The transaction Id |
sendMoney(transaction, senderPublicKey, senderPrivateKey, recipientAddress) ⇒
Sends burst to the blockchain
The message will be broadcasted in two steps.
- Send the sendMoney call with public key to the network
- Take the returned unsigned message and sign it, i.e. the private key won't be transmitted.
Kind: global function
Returns:
The Transaction
Param | Description |
---|
transaction | The unsigned transaction |
senderPublicKey | The senders public key for sending an unsigned message |
senderPrivateKey | The senders private key to sign the message |
recipientAddress | The recipients RS Address |