BitsharesAPI

swapchain documentationBitsharesAPI

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:

NameTypeDescription
accountNamestringThe 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:

NameTypeDescription
accountIDstringThe 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:

NameTypeDescription
senderIDstringThe sender's account ID.
receiverIDstringThe receiver's account ID.
amountnumberThe amount of assets of the HTLC.
hashBufferThe SHA256 hash of the secret.
timelock?undefined | numberThe 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:

NameTypeDescription
senderIDstringID of the sending account.
receiverIDstringID of the receiving account.
secretHashstringHashed 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:

NameTypeDescription
privateKeystringPrivate key of a bitshares account.
networkstringTestnet 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:

NameTypeDescription
nodestringThe endpoint URL to connect.

Returns: Promise‹BitsharesAPI

BitsharesAPI instance.