Skip to main content

React kit (@qorechain/react)

@qorechain/react is the official React layer over @qorechain/sdk: one provider, a handful of hooks, and two drop-in components — including a one-line PQC-status badge. It makes building a dApp with hybrid ML-DSA-87 signing the default path.

npm i @qorechain/react @qorechain/sdk react react-dom

react (>=18) is a peer dependency; @qorechain/sdk is a direct dependency (^0.14.0 since kit 0.14.0; on a 0.x version the caret stays inside 0.14, so an SDK patch does not install a second copy). Use @qorechain/react 0.14.0 (0.9.0 and later work the same way): 0.8.0 pins SDK 0.8.0, which signs the wrong hybrid form on mainnet, and earlier 0.8.x releases can show a stale balance or status after an address change.

Live-network limits of the React kit (0.9.0 to 0.14.0)

useTx connects with the wallet's signer and no post-quantum keypair, so it sends with the classical signature only, which the live networks reject (the Native path requires the hybrid ML-DSA-87 extension): send / sendTokens cannot land a transaction on mainnet or testnet. Send with the SDK's hybrid TxClient (client.connectTx(signer, { pqcKeypair }), see Hybrid signing) for sends. usePqcStatus and <PqcStatusBadge/> read the status through getPqcStatus with the provider's composed client, which since SDK 0.9.0 reads over REST (/qorechain/pqc/v1/account/{address}), so they work against *.qore.host (kit 0.8.x read qor_getPQCKeyStatus, which the public endpoints do not serve, and could not confirm a key there). Balance reads (useBalance) and wallet connection work.

Provider​

Wrap your app once in QoreChainProvider. It holds a single createClient() instance plus the live wallet connection state that every hook reads from.

import { QoreChainProvider } from "@qorechain/react";

function Root() {
return (
<QoreChainProvider
config={{
network: "testnet",
endpoints: {
rpc: "https://rpc-testnet.qore.host",
rest: "https://api-testnet.qore.host",
evmRpc: "https://evm-testnet.qore.host",
},
}}
>
<App />
</QoreChainProvider>
);
}

To switch networks at runtime, remount the provider with a different React key. For tests, pass a pre-built (or mocked) client prop instead of config.

Hooks​

HookReturns
useQoreClient()The composed QoreChainClient for ad-hoc reads.
useAccount(){ addresses, address, isConnected, status, wallet } — native / EVM / SVM addresses.
useBalance(address?, options?){ data, isLoading, error, refetch }; auto-refresh via refreshInterval.
useConnect() / useWallet(){ connect, disconnect, status, isConnecting, error }.
useTx(){ send, sendTokens, status, data, error, isPending, reset }.
usePqcStatus(address?, options?){ data, isRegistered, isLoading, error, refetch }.

Connecting wallets​

useConnect wraps the existing SDK adapters:

const { connect } = useConnect();
await connect({ kind: "keplr" }); // or "leap" | "evm" | "svm"
  • keplr / leap — Cosmos wallets via getCosmosWallet. Suggests and enables the chain, returns a signer that is wired into a TxClient, so useTx can sign immediately. Sets addresses.native.
  • evm — any injected EIP-1193 provider (window.ethereum, e.g. MetaMask) via eth_requestAccounts. Sets addresses.evm.
  • svm — any injected Wallet-Standard provider (window.solana, e.g. Phantom) via connect(). Sets addresses.svm.

The EVM and SVM paths use the injected provider's standard request API directly, so neither viem nor a Solana SDK is pulled in. Pass provider in the connect options to inject a wallet for tests. Pair with @qorechain/evm / @qorechain/svm for full per-VM tooling.

Sending transactions​

import { msg } from "@qorechain/sdk";
import { useTx } from "@qorechain/react";

function Send() {
const { sendTokens, isPending } = useTx();
return (
<button
disabled={isPending}
onClick={() =>
sendTokens("qor1recipient…", [{ denom: "uqor", amount: "1000000" }])
}
>
Send 1 QOR
</button>
);
}

send([{ typeUrl, value }], opts) takes raw messages from the msg.* composers for anything beyond a bank transfer.

Components​

<ConnectButton/>​

A minimal, headless-ish connect / disconnect control. Pass wallets to offer a picker, className / style to theme it, or a children render-prop for full control:

<ConnectButton wallets={["keplr", "leap", "evm"]} />

<PqcStatusBadge/>​

Shows a status indicator when the address has a registered post-quantum key (via usePqcStatus), otherwise a muted "not registered" state. Defaults to the connected account. The default labels are "PQC key registered" and "No PQC key" (override them with safeLabel / unsafeLabel); the root element carries data-pqc-status and data-quantum-safe, with the same values.

<PqcStatusBadge />
<PqcStatusBadge address="qor1…" hideWhenUnsafe />

PqcStatusBadge came with kit 0.11.0. QuantumSafeBadge (with QuantumSafeBadgeProps and QuantumSafeRenderState) is still exported as a deprecated alias of the same component, so existing code keeps working.

Putting it together​

import {
ConnectButton,
PqcStatusBadge,
useAccount,
useBalance,
} from "@qorechain/react";

function Dashboard() {
const { address, isConnected } = useAccount();
const { data: balance } = useBalance(undefined, { refreshInterval: 10_000 });
return (
<>
<ConnectButton wallets={["keplr", "leap", "evm"]} />
{isConnected && (
<p>
{balance?.amount ?? "…"} {balance?.denom} <PqcStatusBadge />
</p>
)}
</>
);
}

See the runnable react-dapp example and the hybrid signing guide for the underlying SDK calls.