web3.js and Kit
Client connections, reads, writes and live subscriptions.
web3.js#
Connect to Kyvro with a standard Connection, then check the genesis hash before trusting anything it tells you.
import { Connection, PublicKey } from "@solana/web3.js";
export const connection = new Connection("https://rpc-testnet.kyvro.si", "confirmed");
const genesis = await connection.getGenesisHash();
if (genesis !== "A8qzbNkAdT1GsqmyKTifWnTgS7PuqqmniwdsGeaPc5Jo") throw new Error("Not Kyvro Testnet");
const balance = await connection.getBalance(new PublicKey("<address>"));
console.log("lamports:", balance);Writes follow the usual pattern: fetch a fresh blockhash, sign locally, send. Transactions expire with their blockhash — on expiry, rebuild with a new one rather than resending.
import { SystemProgram, Transaction } from "@solana/web3.js";
import { connection } from "./connection";
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
const tx = new Transaction({ blockhash, lastValidBlockHeight, feePayer: payer.publicKey })
.add(SystemProgram.transfer({ fromPubkey: payer.publicKey, toPubkey, lamports: 1_000_000 }));
tx.sign(payer);
const signature = await connection.sendRawTransaction(tx.serialize());Kit#
The newer @solana/kit client works the same way: point it at the Kyvro RPC and call standard methods.
import { address, createSolanaRpc } from "@solana/kit";
const rpc = createSolanaRpc("https://rpc-testnet.kyvro.si");
const genesis = await rpc.getGenesisHash().send();
if (genesis !== "A8qzbNkAdT1GsqmyKTifWnTgS7PuqqmniwdsGeaPc5Jo") throw new Error("Not Kyvro Testnet");
const slot = await rpc.getSlot().send();
const { value: balance } = await rpc.getBalance(address("<address>")).send();Live subscriptions#
The WebSocket endpoint at wss://rpc-testnet.kyvro.si speaks standard Solana subscriptions: slot updates, logs and signature confirmations.
import { Connection } from "@solana/web3.js";
const ws = new Connection("https://rpc-testnet.kyvro.si", { commitment: "confirmed", wsEndpoint: "wss://rpc-testnet.kyvro.si" });
const id = ws.onSlotUpdate((update) => console.log("slot", update.slot));Simulating transactions#
There are no debug_* or trace_* methods. Preview what a transaction will do with simulateTransaction, and read execution logs on the explorer(opens in a new tab) after it lands. See JSON-RPC for the full method list.
Something wrong or missing on this page? Send developer feedback.