TypeScript SDK
@genesis/sdk (in sdk/) wraps every contract and includes the ECVRF prover and verifier. It's built on ethers v6.
ts
import { GenesisClient, GenesisDeployment } from "@genesis/sdk";
import { BrowserProvider } from "ethers";
import deployment from "../deployments/elysium.json";
const provider = new BrowserProvider(window.ethereum);
const client = new GenesisClient(deployment as GenesisDeployment, await provider.getSigner());client.vrfCoordinator, client.beacon, client.fairSelection, client.commitReveal, client.automation, client.oracle, client.feeManager and client.staking are ethers Contract instances, with all functions available.
Fees and payments
ts
const fees = await client.quoteVrfFees(); // { hype, genesis | null, genesisSavingsBps }
const fee = fees.genesis ?? fees.hype; // prefer the cheaper GENESIS option
const overrides = await client.preparePayment(fee.token, fee.amount, deployment.contracts.diceRoller);
await client.diceRoller.roll(overrides); // { value } for HYPE, or {} after approving GENESIS| Method | Returns |
|---|---|
quoteVrfFees(account?) | Both prices and the GENESIS saving |
quoteVrfFee(account?, token?) | One price |
preparePayment(token, amount, spender) | { value } for HYPE, or approves GENESIS and returns {} |
genesisToken() / isLaunched() | Launch status |
stake(token, amount) | Stakes, approving first if needed |
symbol(token) | "HYPE" or the ERC-20 symbol |
VRF
ts
const { txHash } = await client.waitForFulfillment(requestId);
const { valid, output } = await client.verifyFulfillment(txHash); // full ECVRF check, locallyLow-level crypto lives under ecvrf:
ts
import { ecvrf } from "@genesis/sdk";
const key = ecvrf.generateKeyPair();
const { proof, output } = ecvrf.prove(key.secretKey, seed);
ecvrf.verify(key.publicKey, proof, seed); // output, or null if invalidOther helpers
| Helper | Use |
|---|---|
latestBeacon() | { round, randomness } |
latestFeedValue(feedId) | { answer, value, decimals, roundId, updatedAt } |
prepareCommitment(roundId, value?) | { value, salt, commitment } for commit–reveal |
computeCommitment(...) | The same hash the contract checks |
computeIndices / computeWeightedIndices | Recompute Fair Selection winners |
signObservation / buildReport | Build oracle reports (for node operators) |