@wkalidev/trivia-quest-sdk
v2.1.0
Published
TriviaQ SDK — Interact with TriviaQ smart contracts — Blockchain quiz game on Celo
Maintainers
Readme
@wkalidev/trivia-quest-sdk
Official SDK for TriviaQ — Blockchain quiz game on Celo & Base Network
Installation
npm install @wkalidev/trivia-quest-sdk
# or
yarn add @wkalidev/trivia-quest-sdkWhat's included
- ✅ Contract addresses (Celo Mainnet + Base Mainnet + Testnet)
- ✅ Full ABIs (TriviaQuest, TriviaDuel, TRIVQ Token)
- ✅ TypeScript types (
Round,Duel,DuelStatus,PlayerStats,LeaderboardEntry) - ✅ Multi-chain helper
getAddress(chainId, contract) - ✅ Score & streak utils (
getMultiplier,calculatePoints,getStreakLabel) - ✅ Duel utils (
formatWager,getDuelNetPrize,isDuelExpired,getDuelStatusLabel) - ✅ Format utils (
formatTrivq,formatCelo,formatAddress) - ✅ MiniPay detection (
isMiniPay,getMiniPayAccount)
Contracts
Celo Mainnet
| Contract | Address |
|---|---|
| TriviaQuest (Game) | 0xffe22d3d1b63866ac9da8ac92fdb9ceddeadb0bb |
| TriviaDuel (1v1) 🆕 | 0xee7be00cd5454b9bea56d864d82076b8b5de5ca1 |
| TRIVQ Token | 0xe65fc5cacaf9a5aebbc0e151dee08a53f24a05c5 |
| DailyCheckIn | 0x8650e6c477f8ae3933dc6d61d85e65c90cf71828 |
| Referral | 0xa0fcd85a25ecb71ca1ea9d63da058c832c27c62e |
Base Mainnet
| Contract | Address |
|---|---|
| TriviaQuest | 0x1e2c209412ec30915ccf922654f0593faf61fcfb |
| TRIVQ Token | 0x8ecc1dc70f3bc5be941b61b42707eb7dbddb54c3 |
| DailyCheckIn | 0x0f19851d5cd905d110c000a7d26d74a2f21f8ff9 |
| Referral | 0x4fb5285263354e1e75f044c65166ab22c3840074 |
Usage
Basic — Read game stats
import {
TRIVIA_QUEST_ADDRESS_CELO,
TRIVQ_TOKEN_ADDRESS_CELO,
CONTRACT_ABI,
TRIVQ_ABI,
formatTrivq,
formatCelo,
} from "@wkalidev/trivia-quest-sdk";
import { createPublicClient, http } from "viem";
import { celo } from "viem/chains";
const client = createPublicClient({ chain: celo, transport: http() });
// Read current round
const round = await client.readContract({
address: TRIVIA_QUEST_ADDRESS_CELO,
abi: CONTRACT_ABI,
functionName: "getCurrentRound",
});
console.log("Prize pool:", formatCelo(round.prizePool));
// Read TRIVQ balance
const balance = await client.readContract({
address: TRIVQ_TOKEN_ADDRESS_CELO,
abi: TRIVQ_ABI,
functionName: "balanceOf",
args: ["0xYOUR_ADDRESS"],
});
console.log("Balance:", formatTrivq(balance));Multi-chain — Get address by chainId
import { getAddress } from "@wkalidev/trivia-quest-sdk";
const gameAddress = getAddress(42220, "game"); // Celo
const duelAddress = getAddress(42220, "duel"); // Celo
const gameBase = getAddress(8453, "game"); // BaseDuel 1v1
import {
DUEL_ADDRESS_CELO,
DUEL_ABI,
formatWager,
getDuelNetPrize,
isDuelExpired,
getDuelStatusLabel,
DuelStatus,
} from "@wkalidev/trivia-quest-sdk";
import { createPublicClient, http } from "viem";
import { celo } from "viem/chains";
const client = createPublicClient({ chain: celo, transport: http() });
// Get open duels
const duels = await client.readContract({
address: DUEL_ADDRESS_CELO,
abi: DUEL_ABI,
functionName: "getOpenDuels",
args: [BigInt(10)],
});
// Format duel info
duels.forEach(duel => {
console.log(`Duel #${duel.id}`);
console.log("Wager:", formatWager(duel.wager));
console.log("Net prize:", formatWager(getDuelNetPrize(duel.wager)));
console.log("Status:", getDuelStatusLabel(duel.status));
console.log("Expired:", isDuelExpired(duel.expiresAt));
});Score & Streak
import {
getMultiplier,
calculatePoints,
getStreakLabel,
} from "@wkalidev/trivia-quest-sdk";
const streak = 4;
console.log(getMultiplier(streak)); // 2
console.log(calculatePoints(true, streak)); // 200
console.log(getStreakLabel(streak)); // "🔥🔥 x2 HOT"MiniPay Detection
import { isMiniPay, getMiniPayAccount } from "@wkalidev/trivia-quest-sdk";
if (isMiniPay()) {
const account = await getMiniPayAccount();
console.log("MiniPay user:", account);
}Types
import type {
Round,
Duel,
DuelStatus,
PlayerStats,
LeaderboardEntry,
} from "@wkalidev/trivia-quest-sdk";
// DuelStatus enum
// DuelStatus.Open = 0
// DuelStatus.Active = 1
// DuelStatus.Finished = 2
// DuelStatus.Cancelled = 3Reward Rates
| Action | Reward | |---|---| | 🎮 Per point scored | 100 TRIVQ | | 🔥 Daily check-in | 100 TRIVQ | | 🎁 7-day streak bonus | 2,000 TRIVQ | | 🔗 Referral reward | 500 TRIVQ | | ⚔️ Duel winner | 90% of total wager |
Changelog
v2.0.0
- Added
DUEL_ABIandDUEL_ADDRESS_CELOfor TriviaDuel 1v1 - Added
BASE_MAINNETcontracts - Added
getAddress(chainId, contract)multi-chain helper - Added duel utils:
formatWager,getDuelNetPrize,isDuelExpired,getDuelStatusLabel - Added format utils:
formatTrivq,formatCelo,formatAddress - Added
TRIVQ_ABIfull token ABI - Added
DuelStatusenum andDueltype - Updated
Roundtype withtopWinnersarray
v1.4.0
- Initial public release
Live Demo
👉 trivia-quest-eight.vercel.app
Author
Built with 💙 by @wkalidev
