BitsharesAPI
swapchain documentation › BitsharesAPI
API to connect to Bitshares blockchain
Implemented as a singleton, so there is only one websocket at the same time. Use getInstance to get an instance and not the constructor.
Hierarchy
- BitsharesAPI
Index
Constructors
Properties
Methods
Constructors
constructor
+ new BitsharesAPI(): BitsharesAPI
Defined in pkg/bitshares/api/api.ts:11
Do not use
Only for testing purposes. If you call the constructor, the websocket will not be open. Use getInstance instead.
Returns: BitsharesAPI
Properties
Static
Private
instance
▪ instance: BitsharesAPI
Defined in pkg/bitshares/api/api.ts:11
Methods
getAccountID
▸ getAccountID(accountName
: string): Promise‹string›
Defined in pkg/bitshares/api/api.ts:43
Get account ID
Parameters:
Name | Type | Description |
---|---|---|
accountName | string | The account name to fetch the ID for. |
Returns: Promise‹string›
The account ID.
getHistory
▸ getHistory(accountID
: string): Promise‹Record‹string, any›[]›
Defined in pkg/bitshares/api/api.ts:54
Get account history
Parameters:
Name | Type | Description |
---|---|---|
accountID | string | The account ID to fetch the history for. |
Returns: Promise‹Record‹string, any›[]›
An array of transaction objects.
getID
▸ getID(senderID
: string, receiverID
: string, amount
: number, hash
: Buffer, timelock?
: undefined | number): Promise‹string›
Defined in pkg/bitshares/api/api.ts:70
Get the HTLC BitShares ID
Parameters:
Name | Type | Description |
---|---|---|
senderID | string | The sender's account ID. |
receiverID | string | The receiver's account ID. |
amount | number | The amount of assets of the HTLC. |
hash | Buffer | The SHA256 hash of the secret. |
timelock? | undefined | number | The timelock in seconds or undefined. |
Returns: Promise‹string›
HTLC ID of an instance.
getPreimageFromHTLC
▸ getPreimageFromHTLC(senderID
: string, receiverID
: string, secretHash
: string): Promise‹string›
Defined in pkg/bitshares/api/api.ts:141
Get preimage from HTLC on blockchain
memberof
BitsharesAPI
Parameters:
Name | Type | Description |
---|---|---|
senderID | string | ID of the sending account. |
receiverID | string | ID of the receiving account. |
secretHash | string | Hashed preimage to verify the HTLC. |
Returns: Promise‹string›
Preimage from the HTLC.
toAccountID
▸ toAccountID(privateKey
: string, network
: string): Promise‹string›
Defined in pkg/bitshares/api/api.ts:106
Derive the account ID from a private key
Parameters:
Name | Type | Description |
---|---|---|
privateKey | string | Private key of a bitshares account. |
network | string | Testnet or mainnet. |
Returns: Promise‹string›
The account ID for the private key.
Static
getInstance
▸ getInstance(node
: string): Promise‹BitsharesAPI›
Defined in pkg/bitshares/api/api.ts:28
Initialize websocket if there is not already one
Parameters:
Name | Type | Description |
---|---|---|
node | string | The endpoint URL to connect. |
Returns: Promise‹BitsharesAPI›
BitsharesAPI instance.