Transanctions

The GraphQL queries that can be performed based on transactions.

Response Interface

export interface TxResponse<T> {
  tx: T;
}

queryTxByAccount

Queries all transactions for a given account.

export async function queryTxByAccount(
  chainId: string,
  address: string,
  minHeight?: number,
  maxHeight?: number
): Promise<TxInfo[]> {
  const resp = await query<QueryTxByAccount, QueryTxByAccountResponse>(
    QUERY_TX_BY_ACCOUNT,
    { minHeight, maxHeight, address, chainId }
  );

  return resp.tx.byAccount;
}

QueryTxByAccount

export interface QueryTxByAccount extends TxQuery {
  address: string;
}

QueryTxByAccountResponse

export type QueryTxByAccountResponse = TxResponse<{
  byAccount: TxInfo[];
}>;

TxInfo

export interface TxInfo {
  code: number;
  gasUsed: number;
  gasWanted: number;
  hash: string;
  height: number;
  rawLog: string;
  tx: Uint8Array;
}

queryTxByContract

Queries all transactions for a given contract address.

export async function queryTxByContract(
  chainId: string,
  contractAddress: string,
  minHeight?: number,
  maxHeight?: number
): Promise<TxInfo[]> {
  const resp = await query<QueryTxByContract, QueryTxByContractResponse>(
    QUERY_TX_BY_CONTRACT,
    { minHeight, maxHeight, contractAddress, chainId }
  );

  return resp.tx.byContract;
}

QueryTxByContract

export interface QueryTxByContract extends TxQuery, ContractAddressQuery {}

QueryTxByContractResponse

export type QueryTxByAccountResponse = TxResponse<{
  byAccount: TxInfo[];
}>;

queryTxByHeight

Queries all transactions for a given height.

export async function queryTxByHeight(height: number): Promise<TxInfo[]> {
  const resp = await query<QueryTxByHeight, QueryTxByHeightResponse>(
    QUERY_TX_BY_HEIGHT,
    { height }
  );

  return resp.tx.byHeight;
}

QueryTxByHeight

export interface QueryTxByHeight {
  height: number;
}

QueryTxByHeightResponse

export type QueryTxByHeightResponse = TxResponse<{
  byHeight: TxInfo[];
}>;

queryTxByHash

Queries a transaction by tx hash.

export async function queryTxByHash(
  chainId: string,
  hash: string
): Promise<TxInfo> {
  const resp = await query<QueryTxByHash, QueryTxByHashResponse>(
    QUERY_TX_BY_HASH,
    { hash, chainId }
  );

  return resp.tx.byHash;
}

QueryTxByHash

export interface QueryTxByHash extends ChainIdQuery {
  hash: string;
}

QueryTxByHashResponse

export type QueryTxByHashResponse = TxResponse<{
  byHash: TxInfo;
}>;

queryAssets

Queries all assets owned by a wallet address.

export async function queryAssets(
  walletAddress: string,
  limit: number,
  offset: number
): Promise<QueryAssetsResponse["assets"]> {
  const resp = await query<QueryAssets, QueryAssetsResponse>(QUERY_ASSETS, {
    walletAddress,
    limit,
    offset,
  });

  return resp.assets;
}

Last updated