Wrapper class for restful api.

### Hierarchy

- RestClient

## Index

### Constructors

- constructor

### Properties

- action
- url
- version

### Methods

- concatParams
- getAllowance
- getBalance
- getBlock
- getBlockHeight
- getBlockHeightByTxHash
- getBlockJson
- getContract
- getContractJson
- getGenerateBlockTime
- getMerkleProof
- getNodeCount
- getRawTransaction
- getRawTransactionJson
- getSmartCodeEvent
- getStorage
- getUrl
- sendRawTransaction

## Constructors

### constructor

- new RestClient(url?: undefined | string): RestClient

- - Defined in network/rest/restClient.ts:42

  #### Parameters

  - ##### Optional url: undefined | string

  #### Returns RestClient

## Properties

### action

action: string = "sendrawtransaction"

- Defined in network/rest/restClient.ts:42

Action name of the request

### url

url: string

- Defined in network/rest/restClient.ts:32

Url of the blockchain node

### version

version: string = "v1.0.0"

- Defined in network/rest/restClient.ts:37

Version of restful api

## Methods

### concatParams

- concatParams(params: Map<string, string>): string

- - Defined in network/rest/restClient.ts:55

  Concat params as the query part

  #### Parameters

  - ##### params: Map<string, string>

  #### Returns string

### getAllowance

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

- - Defined in network/rest/restClient.ts:326

  Get allowance by address

  #### Parameters

  - ##### asset: string

    Asset type. Only ONT or ONG.

  - ##### from: Address

    Address of allowance sender.

  - ##### to: Address

    Address of allowance receiver.

  #### Returns Promise<any>

### getBalance

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

- - Defined in network/rest/restClient.ts:296

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

  #### Parameters

  - ##### address: Address

    Address

  #### Returns Promise<any>

### getBlock

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

- - Defined in network/rest/restClient.ts:187

  Get block by block's height or hash

  #### Parameters

  - ##### value: number | string

    Block height or block hash

  #### Returns Promise<any>

### getBlockHeight

- getBlockHeight(): Promise<any>

- - Defined in network/rest/restClient.ts:176

  Get the current height of the blockchain.

  #### Returns Promise<any>

### getBlockHeightByTxHash

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

- - Defined in network/rest/restClient.ts:257

  Get the block height by reversed transaction hash.

  #### Parameters

  - ##### hash: string

    Reversed transaction hash.

  #### Returns Promise<any>

### getBlockJson

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

- - Defined in network/rest/restClient.ts:307

  Get block info by block's height or hash.

  #### Parameters

  - ##### value: number | string

    Block's height or hash

  #### Returns Promise<any>

### getContract

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

- - Defined in network/rest/restClient.ts:208

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

  #### Parameters

  - ##### codeHash: string

    Code hash of contract.The value is reversed contract address.

  #### Returns Promise<any>

### getContractJson

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

- - Defined in network/rest/restClient.ts:225

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

  #### Parameters

  - ##### codeHash: string

    Code hash of contract.

  #### Returns Promise<any>

### getGenerateBlockTime

- getGenerateBlockTime(): Promise<any>

- - Defined in network/rest/restClient.ts:156

  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/rest/restClient.ts:280

  Get the merkle proof by transaction hash

  #### Parameters

  - ##### hash: string

    Reversed transaction hash

  #### Returns Promise<any>

### getNodeCount

- getNodeCount(): Promise<any>

- - Defined in network/rest/restClient.ts:166

  Get the nodes count of the blockchain.

  #### Returns Promise<any>

### getRawTransaction

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

- - Defined in network/rest/restClient.ts:126

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

  example

        import { utils, Transaction } from 'ontology-ts-sdk';
        const txHash = tx.getHash(); // tx is an instance of Transaction
        restClient.getRawTransaction(utils.reverseHex(txHash)).then(res => {
          const tx = Transaction.deserialize(res.Result)
        })

        `

  #### Parameters

  - ##### txHash: string

    Transactin hash.Always use the reversed value of transaction hash to query.

  #### Returns Promise<any>

### getRawTransactionJson

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

- - Defined in network/rest/restClient.ts:142

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

  #### Parameters

  - ##### txHash: string

    Reversed transaction hash

  #### Returns Promise<any>

### getSmartCodeEvent

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

- - Defined in network/rest/restClient.ts:241

  Get smart contract event by Block height or reversed transaction hash. If the parameter is block height, the result includes all the transaction event of that block; If the parameter is transaction hash, the result is the event of that transaction.

  #### Parameters

  - ##### value: string | number

    Block height or reversed transaction hash

  #### Returns Promise<any>

### getStorage

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

- - Defined in network/rest/restClient.ts:269

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

  #### Parameters

  - ##### codeHash: string

    Code hash of the smart contract

  - ##### key: string

    Key of the stored value

  #### Returns Promise<any>

### getUrl

- getUrl(): string

- - Defined in network/rest/restClient.ts:75

  Get the current blockchain node url

  #### Returns string

### sendRawTransaction

- sendRawTransaction(hexData: string, preExec?: boolean, userId?: undefined | string): Promise<any>

- - Defined in network/rest/restClient.ts:85

  To send raw transaction to blockchian

  #### Parameters

  - ##### hexData: string

    Hex encoded data

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

    Decides if it is a pre-execute transaction

  - ##### Optional userId: undefined | string

    User's id

  #### Returns Promise<any>

Generated using TypeDoc