FairScore Module
Methods for interacting with the FairScore Oracle.
getFairScore
Get the FairScore for a wallet.
async getFairScore(wallet: PublicKey): Promise<FairScoreAccount>Returns
interface FairScoreAccount {
wallet: PublicKey;
score: BN;
activeDaysScore: BN;
socialScore: BN;
transactionHistoryScore: BN;
governanceParticipationScore: BN;
lastUpdated: BN;
updateCount: BN;
}Example
const score = await client.getFairScore(wallet.publicKey);
console.log('Composite Score:', score.score.toNumber());
console.log('Active Days Score:', score.activeDaysScore.toNumber());
console.log('Social Score:', score.socialScore.toNumber());
console.log('Transaction Score:', score.transactionHistoryScore.toNumber());
console.log('Governance Score:', score.governanceParticipationScore.toNumber());getScoreBreakdown
Get a detailed breakdown of the FairScore.
async getScoreBreakdown(wallet: PublicKey): Promise<ScoreBreakdown>Returns
interface ScoreBreakdown {
activeDays: number;
social: number;
transactionHistory: number;
governanceParticipation: number;
composite: number;
}Example
const breakdown = await client.getScoreBreakdown(wallet.publicKey);
console.log('Score Breakdown:');
console.log(' Active Days (20%):', breakdown.activeDays);
console.log(' Social (30%):', breakdown.social);
console.log(' Transactions (20%):', breakdown.transactionHistory);
console.log(' Governance (30%):', breakdown.governanceParticipation);
console.log(' Composite:', breakdown.composite);getScoreHistory
Get historical score records for a wallet.
async getScoreHistory(
wallet: PublicKey,
limit?: number
): Promise<ScoreEntry[]>Parameters
Wallet address to query.
Maximum number of entries to return.
Returns
interface ScoreEntry {
score: number;
timestamp: number;
updater: PublicKey;
}Example
const history = await client.getScoreHistory(wallet.publicKey, 10);
history.forEach(entry => {
console.log({
score: entry.score,
date: new Date(entry.timestamp * 1000).toLocaleDateString(),
});
});getReputationTier
Get the reputation tier for a score.
getReputationTier(score: number): ReputationTierExample
const tier = client.getReputationTier(78);
console.log('Tier:', tier); // 'gold'
const tier2 = client.getReputationTier(92);
console.log('Tier:', tier2); // 'platinum'getTimeLockDuration
Get the time-lock duration for a tier.
getTimeLockDuration(tier: ReputationTier): numberReturns duration in seconds.
Example
const duration = client.getTimeLockDuration('platinum');
console.log('Time-lock:', duration / 3600, 'hours');canSubmitProposal
Check if a tier can submit a proposal type.
canSubmitProposal(tier: ReputationTier, type: ProposalType): booleanExample
const canStandard = client.canSubmitProposal('gold', ProposalType.Standard);
console.log('Can submit standard:', canStandard); // true
const canEmergency = client.canSubmitProposal('gold', ProposalType.Emergency);
console.log('Can submit emergency:', canEmergency); // falseScore Components
| Component | Weight | Factors |
|---|---|---|
| Active Days | 20% | Account age, login frequency |
| Social | 30% | On-chain interactions, reputation |
| Transactions | 20% | Trading volume, protocol usage |
| Governance | 30% | Proposals, votes, badges |
Improving Your Score
Note:
FairScore updates are performed by authorized oracle updaters. Individual actions contribute to scores over time.
Governance Participation (30%)
- Vote on all active proposals
- Submit quality proposals
- Participate in discussions
Social Score (30%)
- Engage in community governance
- Build on-chain reputation
- Contribute to ecosystem
Transaction History (20%)
- Use ecosystem protocols
- Maintain consistent activity
- Build trading history
Active Days (20%)
- Regular protocol interaction
- Consistent governance participation
- Long-term engagement