Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Public Client

createPublicClient is used for chain read/query operations.

Create

import { createPublicClient, http, mainnet } from '@ivem/core'
 
const publicClient = createPublicClient({
  chain: mainnet,
  transport: http(),
})

http() uses chain.rpcUrls[0] by default. For mainnet, this is https://api.iost.io. You can override it via http('https://your-rpc.example').

Methods

The following methods are aligned to IOST node APIs (reference: IOST API).

Chain & Node

  • getChainInfo() -> GET /getChainInfo
  • getNodeInfo() -> GET /getNodeInfo
  • getRAMInfo() -> GET /getRAMInfo

Account & Balance

  • getAccount({ address, reversible? }) -> GET /getAccount/{address}/{reversible}
  • getBalance({ address, token?, useLongestChain? }) -> GET /getTokenBalance/{address}/{token}/{useLongestChain}

Block & Transaction

  • getBlockByHash({ hash, complete? }) -> GET /getBlockByHash/{hash}/{complete}
  • getBlockByNum({ blockNumber, complete? }) -> GET /getBlockByNum/{blockNumber}/{complete}
  • getTxByHash({ hash }) -> GET /getTxByHash/{hash}
  • getTxReceiptByHash({ hash }) -> GET /getTxReceiptByHash/{hash}
  • getTxReceiptByTxHash({ hash }) -> GET /getTxReceiptByTxHash/{hash}

Contract State

  • getContract({ contractID, useLongestChain? }) -> GET /getContract/{contractID}/{useLongestChain}
  • getContractStorage({ contractID, key, field?, byLongestChain? }) -> POST /getContractStorage
  • getContractStorageFields({ contractID, key, byLongestChain? }) -> POST /getContractStorageFields

NFT (Token721)

  • getToken721Balance({ address, token?, useLongestChain? }) -> GET /getToken721Balance/{address}/{token}/{useLongestChain}
  • getToken721Metadata({ token, tokenID, useLongestChain? }) -> GET /getToken721Metadata/{token}/{tokenID}/{useLongestChain}
  • getToken721Owner({ token, tokenID, useLongestChain? }) -> GET /getToken721Owner/{token}/{tokenID}/{useLongestChain}

Receipt Polling

waitForTransactionReceipt({ hash, retryCount?, retryDelay?, timeout?, stage? })

  • stage: "executed" polls getTxByHash and reads transaction.tx_receipt.
  • stage: "irreversible" polls getTxReceiptByTxHash.
  • If stage is omitted, the default is "executed".
  • Resolves when status_code === "SUCCESS".
  • Rejects on explicit failure status_code or timeout/retry overflow.
  • Default timeout: 90_000ms.