Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 2.2 KB

File metadata and controls

59 lines (43 loc) · 2.2 KB

Interacting

Reading state and sending transactions with the q_ client.

Reading state

import { QuantovaClient } from "../src/client.js";
import { rpcUrl } from "../src/config.js";

const client = new QuantovaClient(rpcUrl());

const height  = await client.blockNumber();          // number
const chainId = await client.chainId();               // used to prevent replay
const balance = await client.getBalanceQTOV("Q8f3c…a91b"); // QTOV (base units / 10^18)

Notes:

  • Account addresses are Q-format strings (Q-prefixed), never 0x EVM addresses.
  • Numeric results are QUANTITY hex; the helpers convert them for you.
  • Block references are block-number QUANTITY values — the named tag "latest" is not implemented, so the helpers resolve a height first.

Sending a transaction

The standard path is sign locally, then broadcast:

  1. Build the payload (value, nonce via getNonce, fees, chain id; gas limit for the QVM).
  2. Sign it with the account's post-quantum key using the @quantova SDK keyring (or Qmask.io).
  3. Broadcast the signed payload with sendRawTransaction, then poll for the receipt.
const nonce   = await client.getNonce(myAddress);
// const signed = await account.signTransaction({ to, value, nonce, chainId, gas });
const txHash  = await client.sendRawTransaction(signedTxHex);
const receipt = await client.waitForReceipt(txHash);

Finality

A receipt means the transaction was included. Treat value as settled only after finality (~3 seconds, deterministic) — finalized blocks do not reorg. For anything that moves funds, wait for finality before showing success.

Common q_ methods

Method Returns
q_blockNumber Latest block height (QUANTITY)
q_getBalance QTOV balance in base units (QUANTITY)
q_getTransactionCount Account nonce
q_call Read-only contract return data
q_estimateGas QGAS a call/deployment would consume
q_sendRawTransaction Tx hash for a signed transaction
q_getTransactionReceipt Receipt (status, QGAS used, logs)
q_chainId Chain id (replay protection)

The full reference is in the developer documentation.