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 /getChainInfogetNodeInfo()->GET /getNodeInfogetRAMInfo()->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 /getContractStoragegetContractStorageFields({ 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"pollsgetTxByHashand readstransaction.tx_receipt.stage: "irreversible"pollsgetTxReceiptByTxHash.- If
stageis omitted, the default is"executed". - Resolves when
status_code === "SUCCESS". - Rejects on explicit failure
status_codeor timeout/retry overflow. - Default timeout:
90_000ms.