Websocket client.

TODO: correlate request and response with id, so socket can be reused.

### Hierarchy

- WebsocketClient

## Index

### Constructors

- constructor

### Properties

- debug
- url

### Methods

- getAllowance
- getBalance
- getBlock
- getBlockHeight
- getBlockHeightByTxHash
- getBlockJson
- getContract
- getContractJson
- getGenerateBlockTime
- getMerkleProof
- getNodeCount
- getRawTransaction
- getRawTransactionJson
- getSmartCodeEvent
- getStorage
- send
- sendHeartBeat
- sendRawTransaction
- sendSubscribe

## Constructors

### constructor

- new WebsocketClient(url?: string, debug?: boolean): WebsocketClient

- - Defined in network/websocket/websocketClient.ts:37

  #### Parameters

  - ##### Default value url: string = TEST_ONT_URL.SOCKET_URL

  - ##### Default value debug: boolean = false

  #### Returns WebsocketClient

## Properties

### debug

debug: boolean

- Defined in network/websocket/websocketClient.ts:37

Decides if the client runs in debug mode so it can print info for debug.

### url

url: string

- Defined in network/websocket/websocketClient.ts:33

Url of blockchain node

## Methods

### getAllowance

- getAllowance(asset: string, from: Address, to: Address): Promise<any>

- - Defined in network/websocket/websocketClient.ts:226

  Get allowanece

  #### Parameters

  - ##### asset: string

    Asset's type.Only ONT and ONG supported.

  - ##### from: Address

    Address of allowance's sender.

  - ##### to: Address

    Address of allowance's receiver.

  #### Returns Promise<any>

### getBalance

- getBalance(address: Address): Promise<any>

- - Defined in network/websocket/websocketClient.ts:156

  Get the balance of some address. The result contains ONT and ONG.

  #### Parameters

  - ##### address: Address

    Address

  #### Returns Promise<any>

### getBlock

- getBlock(value: number | string): Promise<any>

- - Defined in network/websocket/websocketClient.ts:136

  Get block's info by block's height or hash. The result is hex encoded string.

  #### Parameters

  - ##### value: number | string

    Block's height or hash

  #### Returns Promise<any>

### getBlockHeight

- getBlockHeight(): Promise<any>

- - Defined in network/websocket/websocketClient.ts:126

  Get current block height

  #### Returns Promise<any>

### getBlockHeightByTxHash

- getBlockHeightByTxHash(hash: string): Promise<any>

- - Defined in network/websocket/websocketClient.ts:196

  Get block's height by transaction hash

  #### Parameters

  - ##### hash: string

    Reversed transaction hash

  #### Returns Promise<any>

### getBlockJson

- getBlockJson(value: number | string): Promise<any>

- - Defined in network/websocket/websocketClient.ts:146

  Get block's info by block's height or hash. The result is json.

  #### Parameters

  - ##### value: number | string

    Block's height or hash

  #### Returns Promise<any>

### getContract

- getContract(hash: string): Promise<any>

- - Defined in network/websocket/websocketClient.ts:166

  Get contract info by code hash. The result is hex encoded string.

  #### Parameters

  - ##### hash: string

    Contract's code hash.

  #### Returns Promise<any>

### getContractJson

- getContractJson(hash: string): Promise<any>

- - Defined in network/websocket/websocketClient.ts:176

  Get contract's info by code hash The result is json.

  #### Parameters

  - ##### hash: string

    Contract's code hash

  #### Returns Promise<any>

### getGenerateBlockTime

- getGenerateBlockTime(): Promise<any>

- - Defined in network/websocket/websocketClient.ts:110

  Get the generation time for each block. If the blockchain node runs in vbft, the result is null.

  #### Returns Promise<any>

### getMerkleProof

- getMerkleProof(hash: string): Promise<any>

- - Defined in network/websocket/websocketClient.ts:215

  Get merkle proof by transaction hash.

  #### Parameters

  - ##### hash: string

    Reversed transaction hash

  #### Returns Promise<any>

### getNodeCount

- getNodeCount(): Promise<any>

- - Defined in network/websocket/websocketClient.ts:118

  Get Nodes count

  #### Returns Promise<any>

### getRawTransaction

- getRawTransaction(txHash: string): Promise<any>

- - Defined in network/websocket/websocketClient.ts:91

  Get raw transaction by transaction hash. The result is hex encoded transaction.

  #### Parameters

  - ##### txHash: string

    Reversed transaction hash

  #### Returns Promise<any>

### getRawTransactionJson

- getRawTransactionJson(txHash: string): Promise<any>

- - Defined in network/websocket/websocketClient.ts:101

  Get transaction info by transaction hash. The result is json.

  #### Parameters

  - ##### txHash: string

    Reversed transaction hash

  #### Returns Promise<any>

### getSmartCodeEvent

- getSmartCodeEvent(value: number | string): Promise<any>

- - Defined in network/websocket/websocketClient.ts:187

  Get smart conde event by transaction hash or block's height. If parameter is transaction hash, the result is the event of that transaction. If parameter is block's height, the result is all the events of that block.

  #### Parameters

  - ##### value: number | string

    Reversed transaction hash or block's height

  #### Returns Promise<any>

### getStorage

- getStorage(codeHash: string, key: string): Promise<any>

- - Defined in network/websocket/websocketClient.ts:206

  Get stored value in smart contract by contract's code hash and the key.

  #### Parameters

  - ##### codeHash: string

    Contract's code hash

  - ##### key: string

    Key of stored value

  #### Returns Promise<any>

### Private send

- send(raw: string, waitNotify?: boolean): Promise<any>

- - Defined in network/websocket/websocketClient.ts:236

  Send msg to blockchain

  #### Parameters

  - ##### raw: string

    Message to send

  - ##### Default value waitNotify: boolean = false

    Decides if need to wait for notify from blockchain

  #### Returns Promise<any>

### sendHeartBeat

- sendHeartBeat(): Promise<any>

- - Defined in network/websocket/websocketClient.ts:47

  Send heart beat request

  #### Returns Promise<any>

### sendRawTransaction

- sendRawTransaction(hexData: string, preExec?: boolean, waitNotify?: boolean): Promise<any>

- - Defined in network/websocket/websocketClient.ts:81

  Send raw transaction

  #### Parameters

  - ##### hexData: string

    Hex encoded data

  - ##### Default value preExec: boolean = false

    Decides if it is a pre-executed transaction

  - ##### Default value waitNotify: boolean = false

    Decides if client waits for notify from blockchain.

  #### Returns Promise<any>

### sendSubscribe

- sendSubscribe(subscribeEvent?: boolean, subscribeJsonBlock?: boolean, subscribeRawBlock?: boolean, subscribeBlockTxHashes?: boolean): Promise<any>

- - Defined in network/websocket/websocketClient.ts:59

  Send subscribe request

  #### Parameters

  - ##### Default value subscribeEvent: boolean = false

  - ##### Default value subscribeJsonBlock: boolean = false

  - ##### Default value subscribeRawBlock: boolean = false

  - ##### Default value subscribeBlockTxHashes: boolean = false

  #### Returns Promise<any>

Generated using TypeDoc