type WalletScore = {
id: string;
address: string;
finalScore: number;
breakdown: {
age_factor: number;
activity_factor: number;
wallet_age_days: number | null;
total_txs: number;
chains_active: number;
last_tx_days_ago: number | null;
};
bonuses: { ens: number; multichain: number; rewards: number };
penalties: { recency: number; humanity: number; bot: number };
dataSources: { etherscan: boolean; rewards: boolean };
cached: boolean;
cachedAt: string | null;
};
async function getWalletScore(address: string, force = false): Promise<WalletScore> {
const url = new URL("https://api.rewards.so/score");
url.searchParams.set("address", address);
if (force) url.searchParams.set("force", "true");
const res = await fetch(url.toString(), {
headers: { Authorization: `Bearer ${process.env.REWARDS_API_KEY}` },
});
if (!res.ok) {
const { error } = await res.json();
throw new Error(`Score API error: ${error}`);
}
return res.json();
}
// Check if a wallet is trustworthy before granting access
const score = await getWalletScore("0xd8da6bf26964af9d7eed9e03e53415d37aa96045");
if (score.finalScore < 30) {
console.log("Low-reputation wallet — consider additional verification");
} else {
console.log(`Score: ${score.finalScore}/100 — wallet age: ${score.breakdown.wallet_age_days}d`);
}