The OCAP Client interacts with the blockchain through GraphQL. Methods are categorized into two main types:
- Queries: These are read-only operations used to fetch data from the blockchain, such as retrieving the state of an account, listing transactions, or getting general chain information. They do not alter the state of the chain.
- Mutations: These are write operations that modify the state of the blockchain. Sending a transaction is the primary example of a mutation.
This section provides a complete reference for all available query and mutation methods provided by the client.
Query Methods#
Queries are used to retrieve data from the blockchain. Here is a complete list of all available query methods.
getAccountState#
Retrieves the current state of a specific account, including its balance, nonce, and other details.
Parameters
The address of the account to query.
Query the state at a specific block height.
Specific fields to retrieve.
If true, traces the account's migration history.
Returns
ResponseGetAccountState
object
An object containing the response code and the account state.
getAssetState#
Retrieves the current state of a specific asset (NFT).
Parameters
The address of the asset to query.
Query the state at a specific block height.
Specific fields to retrieve.
Returns
ResponseGetAssetState
object
An object containing the response code and the asset state.
getFactoryState#
Fetches the state of a specific asset factory.
Parameters
The address of the factory to query.
Returns
ResponseGetFactoryState
object
An object containing the response code and the factory state.
getDelegateState#
Retrieves the state of a delegation relationship.
Parameters
The address of the delegation to query.
Query the state at a specific block height.
Specific fields to retrieve.
Returns
ResponseGetDelegateState
object
An object containing the response code and the delegation state.
getTokenState#
Fetches the state of a specific fungible token.
Parameters
The address of the token to query.
Returns
ResponseGetTokenState
object
An object containing the response code and the token state.
getEvidenceState#
Retrieves an evidence record by its hash.
Parameters
The hash of the evidence to retrieve.
Returns
ResponseGetEvidenceState
object
An object containing the response code and the evidence state.
getForgeState#
Fetches the overall configuration and state of the OCAP blockchain.
Parameters
Query the state at a specific block height.
Specific fields to retrieve.
Returns
ResponseGetForgeState
object
An object containing the response code and the chain state.
getTokenFactoryState#
Retrieves the state of a specific token factory.
Parameters
The address of the token factory to query.
Returns
ResponseGetTokenFactoryState
object
An object containing the response code and the token factory state.
getTx#
Fetches a single transaction by its hash.
Parameters
The hash of the transaction to retrieve.
Returns
An object containing the response code and transaction details.
getBlock#
Retrieves a single block by its height.
Parameters
The height of the block to retrieve.
Returns
An object containing the response code and block details.
getBlocks#
Retrieves a list of blocks, with optional filters.
Parameters
heightFilter
RangeFilterInput
Filter blocks by a height range.
If true, blocks with no transactions are excluded.
Returns
An object containing pagination info and a list of blocks.
getUnconfirmedTxs#
Fetches transactions that are in the mempool but not yet confirmed.
Parameters
Returns
ResponseGetUnconfirmedTxs
object
An object containing pagination info and a list of unconfirmed transactions.
getChainInfo#
Retrieves general information about the blockchain.
Parameters
This method does not take any parameters.
Returns
ResponseGetChainInfo
object
An object containing the response code and chain information.
getConfig#
Fetches the node's configuration.
Parameters
If true, returns the parsed configuration.
Returns
An object containing the response code and the configuration.
getNetInfo#
Retrieves network information, including connected peers.
Parameters
This method does not take any parameters.
Returns
An object containing the response code and network information.
getNodeInfo#
Retrieves information about the specific node being queried.
Parameters
This method does not take any parameters.
Returns
ResponseGetNodeInfo
object
An object containing the response code and node information.
getValidatorsInfo#
Fetches information about the current set of validators.
Parameters
This method does not take any parameters.
Returns
ResponseGetValidatorsInfo
object
An object containing the response code and validators information.
getForgeStats#
Retrieves various statistics about the blockchain's activity.
Parameters
This method does not take any parameters.
Returns
ResponseGetForgeStats
object
An object containing the response code and chain statistics.
listAssetTransactions#
Lists all transactions related to a specific asset.
Parameters
The address of the asset.
Returns
ResponseListAssetTransactions
object
An object containing pagination info and a list of transactions.
listAssets#
Lists all assets, with filters for owner or factory.
Parameters
Filter assets by the owner's address.
Filter assets by the factory's address.
timeFilter
TimeFilterInput
Filter assets by a time range.
Returns
An object containing pagination info and a list of assets.
listBlocks#
Lists blocks with various filtering options.
Parameters
Filter blocks by the proposer's address.
timeFilter
TimeFilterInput
Filter blocks by a time range.
heightFilter
RangeFilterInput
Filter blocks by a height range.
numTxsFilter
RangeFilterInput
Filter blocks by the number of transactions.
numInvalidTxsFilter
RangeFilterInput
Filter blocks by the number of invalid transactions.
Returns
An object containing pagination info and a list of blocks.
listTopAccounts#
Lists accounts with the highest balance of a specific token.
Parameters
The address of the token. If not provided, it defaults to the native token.
timeFilter
TimeFilterInput
Filter accounts by a time range.
Returns
ResponseListTopAccounts
object
An object containing pagination info and a list of top accounts.
listTransactions#
A powerful method to list transactions with a wide range of filters.
Parameters
timeFilter
TimeFilterInput
Filter transactions by a time range.
addressFilter
AddressFilterInput
Filter transactions by sender or receiver address.
typeFilter
TypeFilterInput
Filter by transaction type.
validityFilter
ValidityFilterInput
Filter by transaction validity.
factoryFilter
FactoryFilterInput
Filter by factory address.
tokenFilter
TokenFilterInput
Filter by token address.
assetFilter
AssetFilterInput
Filter by asset address.
accountFilter
AccountFilterInput
Filter by account address.
Filter by transaction hash.
rollupFilter
RollupFilterInput
Filter by rollup address.
stakeFilter
StakeFilterInput
Filter by stake address.
delegationFilter
DelegationFilterInput
Filter by delegation address.
tokenFactoryFilter
TokenFactoryFilterInput
Filter by token factory address.
Returns
ResponseListTransactions
object
An object containing pagination info and a list of transactions.
listTokens#
Lists all fungible tokens on the chain.
Parameters
Filter tokens by the issuer's address.
timeFilter
TimeFilterInput
Filter tokens by a time range.
Returns
An object containing pagination info and a list of tokens.
listFactories#
Lists all asset factories on the chain.
Parameters
Filter factories by the owner's address.
A list of factory addresses to query.
timeFilter
TimeFilterInput
Filter factories by a time range.
Returns
ResponseListFactories
object
An object containing pagination info and a list of factories.
getAccountTokens#
Retrieves the token balances for a specific account.
Parameters
The address of the account.
Specific token address to query.
Returns
ResponseGetAccountTokens
object
An object containing the response code and a list of account tokens.
getStakeState#
Fetches the state of a specific stake.
Parameters
The address of the stake to query.
Query the state at a specific block height.
Specific fields to retrieve.
Returns
ResponseGetStakeState
object
An object containing the response code and the stake state.
listStakes#
Lists all stake records, with optional filters.
Parameters
addressFilter
AddressFilterInput
Filter stakes by sender or receiver address.
timeFilter
TimeFilterInput
Filter stakes by a time range.
assetFilter
AssetFilterInput
Filter stakes by asset address.
Returns
An object containing pagination info and a list of stakes.
getRollupState#
Retrieves the state of a specific rollup.
Parameters
The address of the rollup to query.
Query the state at a specific block height.
Specific fields to retrieve.
Returns
ResponseGetRollupState
object
An object containing the response code and the rollup state.
listRollups#
Lists all rollups on the chain.
Parameters
Filter rollups by token address.
foreignTokenAddress
string
Filter rollups by foreign token address.
timeFilter
TimeFilterInput
Filter rollups by a time range.
Returns
ResponseListRollups
object
An object containing pagination info and a list of rollups.
getRollupBlock#
Fetches a specific block from a rollup sidechain.
Parameters
The hash of the rollup block.
The height of the rollup block.
rollupAddress
string
required
The address of the rollup.
Returns
ResponseGetRollupBlock
object
An object containing the response code and the rollup block.
listRollupBlocks#
Lists blocks from a rollup sidechain.
Parameters
rollupAddress
string
required
The address of the rollup.
Filter by proposer address.
validatorFilter
ValidatorFilterInput
Filter by validator.
Filter by transaction hash.
timeFilter
TimeFilterInput
Filter by time range.
Returns
ResponseListRollupBlocks
object
An object containing pagination info and a list of rollup blocks.
listRollupValidators#
Lists the validators for a specific rollup.
Parameters
rollupAddress
string
required
The address of the rollup.
Returns
ResponseListRollupValidators
object
An object containing pagination info and a list of rollup validators.
listDelegations#
Lists all delegation records.
Parameters
Filter by the delegator's address.
Filter by the delegatee's address.
timeFilter
TimeFilterInput
Filter by time range.
Returns
ResponseListDelegations
object
An object containing pagination info and a list of delegations.
search#
Performs a keyword search for accounts, assets, or transactions.
Parameters
The keyword to search for.
Returns
An object containing pagination info and search results.
estimateGas#
Estimates the gas required for a transaction.
Parameters
The type URL of the transaction.
The encoded transaction string.
Returns
ResponseEstimateGas
object
An object containing the response code and the gas estimate.
listTokenFlows#
Traces the flow of tokens between accounts.
Parameters
accountAddress
string
required
The address of the account to trace.
The address of the token to trace.
direction
TokenFlowDirection
The direction of the flow (IN or OUT).
Returns
ResponseListTokenFlows
object
An object containing pagination info and token flow data.
verifyAccountRisk#
Assesses the risk profile of a given account.
Parameters
accountAddress
string
required
The address of the account to verify.
The address of the token for context.
Returns
ResponseVerifyAccountRisk
object
An object containing the response code and the risk verification result.
getTokenDistribution#
Retrieves the distribution statistics for a given token.
Parameters
tokenAddress
string
required
The address of the token.
Returns
ResponseGetTokenDistribution
object
An object containing the response code and token distribution data.
listTokenFactories#
Lists all token factories on the chain.
Parameters
Filter by reserve token address.
timeFilter
TimeFilterInput
Filter by time range.
Returns
ResponseListTokenFactories
object
An object containing pagination info and a list of token factories.
Mutation Methods#
Mutations are used to send transactions that modify the state of the blockchain.
sendTx#
Broadcasts a pre-signed transaction to the network. This is the fundamental method for all write operations. For creating and signing transactions, see the High-level API and Transaction Lifecycle guides.
Parameters
The encoded transaction string.
The wallet object used for signing.
Authentication token, if required.
commit
boolean
default:true
If true, waits for the transaction to be committed to a block.
Extra data to be included.
Returns
An object containing the response code and the transaction hash.
Example
// This example assumes `signedTx` is a properly encoded and signed transaction string.
// See other guides for how to create it.
const signedTx = '...';
const wallet = { ... }; // The wallet that signed the transaction
try {
const { hash } = await client.sendTx({ tx: signedTx, wallet });
console.log('Transaction sent successfully! Hash:', hash);
} catch (error) {
console.error('Failed to send transaction:', error);
}