Reputation
On-chain reputation scoring with authority-managed point system
Deployed
Anchor 0.32
Program ID
ChWH3iGNS4cwrpH1jz1BRVZqVteS177yr6Pe4Y8MFBQ
Repository
ExpertVagabond/solana-reputation
Binary Size
247K
Cluster
Devnet
Instructions
IX
initialize
Creates a new reputation system with a named configuration managed by the authority.
| Parameter | Type | Description |
|---|---|---|
name | String | Name of the reputation system (max 32 characters) |
IX
add_points
Awards reputation points to a wallet address. Only callable by the authority.
| Parameter | Type | Description |
|---|---|---|
amount | u64 | Number of reputation points to add |
reason_hash | [u8; 32] | SHA-256 hash of the reason for awarding points |
IX
remove_points
Removes reputation points from a wallet address. Only callable by the authority.
| Parameter | Type | Description |
|---|---|---|
amount | u64 | Number of reputation points to remove |
reason_hash | [u8; 32] | SHA-256 hash of the reason for removing points |
Accounts
ReputationConfig
| Field | Type | Description |
|---|---|---|
authority | Pubkey | Admin who manages the reputation system |
name | String | Name of the reputation system |
total_users | u64 | Total number of wallets with reputation accounts |
bump | u8 | PDA bump seed |
ReputationAccount
| Field | Type | Description |
|---|---|---|
config | Pubkey | The reputation config this account belongs to |
wallet | Pubkey | Wallet address of the reputation holder |
points | u64 | Current reputation score |
history_count | u64 | Number of point changes recorded |
last_update | i64 | Timestamp of the last point modification |
bump | u8 | PDA bump seed |
PDA Derivation
config
seeds = [b"config", authority]
reputation
seeds = [b"reputation", config, wallet]
Error Codes
NameTooLong
Reputation system name exceeds the maximum 32 character limit
InsufficientPoints
Cannot remove more points than the wallet currently holds
Overflow
Arithmetic overflow in point calculation
Usage Example
import { Program, BN } from "@coral-xyz/anchor"; import { PublicKey } from "@solana/web3.js"; import { createHash } from "crypto"; // Derive config PDA const [configPda] = PublicKey.findProgramAddressSync( [Buffer.from("config"), authority.publicKey.toBuffer()], program.programId ); // Derive reputation PDA for a specific wallet const [repPda] = PublicKey.findProgramAddressSync( [Buffer.from("reputation"), configPda.toBuffer(), userWallet.toBuffer()], program.programId ); // Add 100 reputation points const reason = createHash("sha256").update("Completed community task").digest(); await program.methods .addPoints(new BN(100), [...reason]) .accounts({ config: configPda, reputation: repPda, authority: authority.publicKey, wallet: userWallet, }) .signers([authority]) .rpc();