Options
All
  • Public
  • Public/Protected
  • All
Menu

Wrapper class for restful api.

Hierarchy

  • RestClient

Index

Constructors

constructor

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

Properties

action

action: string = "sendrawtransaction"

Action name of the request

url

url: string

Url of the blockchain node

version

version: string = "v1.0.0"

Version of restful api

Methods

concatParams

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

getAllowance

  • getAllowance(asset: string, from: Address, to: Address): Promise<any>
  • 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>

getBlock

  • getBlock(value: number | string): Promise<any>
  • Get block by block's height or hash

    Parameters

    • value: number | string

      Block height or block hash

    Returns Promise<any>

getBlockHeight

  • getBlockHeight(): Promise<any>

getBlockHeightByTxHash

  • getBlockHeightByTxHash(hash: string): Promise<any>
  • Get the block height by reversed transaction hash.

    Parameters

    • hash: string

      Reversed transaction hash.

    Returns Promise<any>

getBlockJson

  • getBlockJson(value: number | string): Promise<any>
  • 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>
  • 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>
  • Get contract info by code hash. The result is json.

    Parameters

    • codeHash: string

      Code hash of contract.

    Returns Promise<any>

getGenerateBlockTime

  • getGenerateBlockTime(): Promise<any>
  • 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>
  • Get the merkle proof by transaction hash

    Parameters

    • hash: string

      Reversed transaction hash

    Returns Promise<any>

getNodeCount

  • getNodeCount(): Promise<any>

getRawTransaction

  • getRawTransaction(txHash: string): Promise<any>
  • 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>
  • 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>
  • 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>
  • 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

sendRawTransaction

  • sendRawTransaction(hexData: string, preExec?: boolean, userId?: undefined | string): Promise<any>
  • 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