Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ChainRpc

Hierarchy

  • ChainRpc

Index

Methods

getAsset

  • getAsset(txhash: H256 | string, index: number, blockNumber?: undefined | number): Promise<Asset | null>
  • Gets asset of given transaction hash and index.

    Parameters

    • txhash: H256 | string

      The tx hash of AssetMintTransaction or AssetTransferTransaction.

    • index: number

      The index of output in the transaction.

    • Optional blockNumber: undefined | number

      The specific block number to get the asset from

    Returns Promise<Asset | null>

    Asset, if asset exists, Else, returns null.

getAssetSchemeByHash

  • getAssetSchemeByHash(txhash: H256 | string, shardId: number, worldId: number): Promise<AssetScheme | null>
  • Gets asset scheme of given hash of AssetMintTransaction.

    Parameters

    • txhash: H256 | string

      The tx hash of AssetMintTransaction.

    • shardId: number

      The shard id of Asset Scheme.

    • worldId: number

      The world id of Asset Scheme.

    Returns Promise<AssetScheme | null>

    AssetScheme, if asset scheme exists. Else, returns null.

getAssetSchemeByType

  • getAssetSchemeByType(assetType: H256 | string): Promise<AssetScheme | null>
  • Gets asset scheme of asset type

    Parameters

    • assetType: H256 | string

      The type of Asset.

    Returns Promise<AssetScheme | null>

    AssetScheme, if asset scheme exists. Else, returns null.

getBalance

  • getBalance(address: PlatformAddress | string, blockNumber?: undefined | number): Promise<U256>
  • Gets balance of an account of given address, recorded in the block of given blockNumber. If blockNumber is not given, then returns balance recorded in the most recent block.

    Parameters

    • address: PlatformAddress | string

      An account address

    • Optional blockNumber: undefined | number

      The specific block number to get account's balance at given address.

    Returns Promise<U256>

    Balance of account at specified block.

getBestBlockNumber

  • getBestBlockNumber(): Promise<number>
  • Gets number of the latest block.

    Returns Promise<number>

    Number of the latest block.

getBlock

  • getBlock(hashOrNumber: H256 | string | number): Promise<Block | null>
  • Gets block of given block hash.

    Parameters

    • hashOrNumber: H256 | string | number

      The block hash or number of which to get the block of

    Returns Promise<Block | null>

    Block, if block exists. Else, returns null.

getBlockHash

  • getBlockHash(blockNumber: number): Promise<H256 | null>
  • Gets block hash of given blockNumber.

    Parameters

    • blockNumber: number

      The block number of which to get the block hash of.

    Returns Promise<H256 | null>

    BlockHash, if block exists. Else, returns null.

getNetworkId

getNonce

  • Gets nonce of an account of given address, recorded in the block of given blockNumber. If blockNumber is not given, then returns nonce recorded in the most recent block.

    Parameters

    • address: PlatformAddress | string

      An account address

    • Optional blockNumber: undefined | number

      The specific block number to get account's nonce at given address.

    Returns Promise<U256>

    Nonce of account at specified block.

getParcel

  • Gets SignedParcel of given hash. Else returns null.

    Parameters

    • hash: H256 | string

      SignedParcel's hash

    Returns Promise<SignedParcel | null>

    SignedParcel, or null when SignedParcel was not found.

getParcelInvoice

  • getParcelInvoice(parcelHash: H256 | string, options?: object): Promise<Invoice[] | Invoice | null>
  • Gets invoices of given parcel.

    Parameters

    • parcelHash: H256 | string

      The parcel hash of which to get the corresponding parcel of.

    • Default value options: object = {}
      • Optional timeout?: undefined | number

        Indicating milliseconds to wait the parcel to be confirmed.

    Returns Promise<Invoice[] | Invoice | null>

    List of invoice, or null when no such parcel exists.

getPendingParcels

  • Gets pending parcels.

    Returns Promise<SignedParcel[]>

    List of SignedParcel, with each parcel has null for blockNumber/blockHash/parcelIndex.

getRegularKey

  • getRegularKey(address: PlatformAddress | string, blockNumber?: undefined | number): Promise<H512>
  • Gets the regular key of an account of given address, recorded in the block of given blockNumber. If blockNumber is not given, then returns the regular key in the most recent block.

    Parameters

    • address: PlatformAddress | string

      An account address

    • Optional blockNumber: undefined | number

      The specific block number to get account's regular key at given address.

    Returns Promise<H512>

    The regular key of account at specified block.

getTransaction

  • Gets a transaction of given hash.

    Parameters

    • txhash: H256 | string

      The transaction hash of which to get the corresponding transaction of.

    Returns Promise<Transaction | null>

    A transaction, or null when transaction of given hash not exists.

getTransactionInvoice

  • getTransactionInvoice(txhash: H256 | string, options?: object): Promise<Invoice | null>
  • Gets invoice of a transaction of given hash.

    Parameters

    • txhash: H256 | string

      The transaction hash of which to get the corresponding transaction of.

    • Default value options: object = {}
      • Optional timeout?: undefined | number

        Indicating milliseconds to wait the transaction to be confirmed.

    Returns Promise<Invoice | null>

    Invoice, or null when transaction of given hash not exists.

isAssetSpent

  • isAssetSpent(txhash: H256 | string, index: number, shardId: number, blockNumber?: undefined | number): Promise<boolean | null>
  • Checks whether an asset is spent or not.

    Parameters

    • txhash: H256 | string

      The tx hash of AssetMintTransaction or AssetTransferTransaction.

    • index: number

      The index of output in the transaction.

    • shardId: number

      The shard id of an Asset.

    • Optional blockNumber: undefined | number

      The specific block number to get the asset from.

    Returns Promise<boolean | null>

    True, if the asset is spent. False, if the asset is not spent. Null, if no such asset exists.

sendParcel

  • sendParcel(parcel: Parcel, options?: undefined | object): Promise<H256>
  • Signs a parcel with the given account and sends it to CodeChain's network.

    throws

    When the given account cannot afford to pay the fee

    throws

    When the given fee is too low

    throws

    When the given nonce does not match

    throws

    When the given account is unknown

    throws

    When the given passphrase does not match

    Parameters

    • parcel: Parcel

      The parcel to send

    • Optional options: undefined | object

    Returns Promise<H256>

    SignedParcel's hash

sendSignedParcel

  • Sends SignedParcel to CodeChain's network.

    Parameters

    Returns Promise<H256>

    SignedParcel's hash.

Generated using TypeDoc