Contract e48f0e9939ceb39d6daa0e909355bc36642cd54aabbbd19db93ad02723600a34

← Back to Index 📥 Download WASM

Meta

cliver 25.2.0#
rssdkver 23.4.1#e671b396f8bacf1370925f722df158b31c0baae5
rsver 1.94.0

Instances

  • CDI7BKSAMLH74OMOMGQYG6Z2DQOAHK7YTV6LZ4NV3OUWQ3V6AZFXEZLK

Interface

fn has_role(
    env: soroban_sdk::Env,
    account: soroban_sdk::Address,
    role: soroban_sdk::Symbol,
) -> Option
fn get_admin(env: soroban_sdk::Env) -> Option

Get a user's current level.

Arguments

  • user - Address to query

Returns

The user's level as u32 (0=Rookie, 1=Bronze, 2=Silver, 3=Gold, 4=Diamond)

fn get_level(env: soroban_sdk::Env, user: soroban_sdk::Address) -> u32

Get a user's total points.

Arguments

  • user - Address to query

Returns

The user's total points

fn get_points(env: soroban_sdk::Env, user: soroban_sdk::Address) -> u32
fn grant_role(
    env: soroban_sdk::Env,
    account: soroban_sdk::Address,
    role: soroban_sdk::Symbol,
    caller: soroban_sdk::Address,
)

Get the config role symbol.

fn config_role(env: soroban_sdk::Env) -> soroban_sdk::Symbol
fn revoke_role(
    env: soroban_sdk::Env,
    account: soroban_sdk::Address,
    role: soroban_sdk::Symbol,
    caller: soroban_sdk::Address,
)

Record a reputation event for a user.

Requires the "recorder" role.

Arguments

  • caller - Address initiating the record (must have recorder role)
  • user - Address receiving the reputation points
  • event_type - Type of event being recorded

Returns

The user's new total points

fn record_event(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    user: soroban_sdk::Address,
    event_type: EventType,
) -> u32

Initialize the Reputation contract.

Arguments

  • admin - Address that will have admin privileges and can grant roles
  • nft_contract - Optional NFT contract address for integration

Errors

  • Error::AlreadyInitialized - If the contract has already been initialized
fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    nft_contract: Option,
)

Get the recorder role symbol.

fn recorder_role(env: soroban_sdk::Env) -> soroban_sdk::Symbol
fn renounce_role(
    env: soroban_sdk::Env,
    role: soroban_sdk::Symbol,
    caller: soroban_sdk::Address,
)
fn get_role_admin(
    env: soroban_sdk::Env,
    role: soroban_sdk::Symbol,
) -> Option
fn renounce_admin(env: soroban_sdk::Env)
fn set_role_admin(
    env: soroban_sdk::Env,
    role: soroban_sdk::Symbol,
    admin_role: soroban_sdk::Symbol,
)

Calculate what level a given point total would achieve.

Arguments

  • points - Point total to evaluate

Returns

The level as u32

fn calculate_level(env: soroban_sdk::Env, points: u32) -> u32
fn get_role_member(
    env: soroban_sdk::Env,
    role: soroban_sdk::Symbol,
    index: u32,
) -> soroban_sdk::Address

Get a user's event history.

Arguments

  • user - Address to query

Returns

Vector of ReputationEventRecord

fn get_user_events(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
) -> soroban_sdk::Vec

Check if a user meets a permission threshold.

Arguments

  • user - Address to check
  • threshold_type - Type of threshold to check against

Returns

True if user's level meets or exceeds the threshold

fn meets_threshold(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    threshold_type: ThresholdType,
) -> bool

Set the NFT contract address for integration.

Only admin can call this function.

Arguments

  • caller - Admin address
  • nft_address - NFT contract address
fn set_nft_contract(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    nft_address: soroban_sdk::Address,
)

Register a user's NFT token ID.

Requires the "recorder" role.

Arguments

  • caller - Address initiating the registration (must have recorder role)
  • user - User address
  • token_id - NFT token ID to register
fn register_user_nft(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    user: soroban_sdk::Address,
    token_id: u32,
)

Get the point threshold for a specific level.

Arguments

  • level - Level to query (0-4)

Returns

Points required for that level

fn get_level_threshold(env: soroban_sdk::Env, level: u32) -> u32
fn transfer_admin_role(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
    live_until_ledger: u32,
)

Set level thresholds.

Requires the "config" role.

Arguments

  • caller - Address initiating the update (must have config role)
  • thresholds - Map of level (u32) to point threshold
fn set_level_thresholds(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    thresholds: soroban_sdk::Map,
)
fn accept_admin_transfer(env: soroban_sdk::Env)

Get the point value for a specific event type.

Arguments

  • event_type - Event type to query

Returns

Points awarded for that event type

fn get_event_point_value(env: soroban_sdk::Env, event_type: EventType) -> u32
fn get_role_member_count(env: soroban_sdk::Env, role: soroban_sdk::Symbol) -> u32

Get the NFT token ID registered for a user.

Arguments

  • user - Address to query

Returns

Option containing the token ID if registered

fn get_user_nft_token_id(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
) -> Option

Set event point values.

Requires the "config" role.

Arguments

  • caller - Address initiating the update (must have config role)
  • event_points - Map of EventType to point value
fn set_event_point_values(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    event_points: soroban_sdk::Map,
)

Record a reputation event with custom points.

Requires the "recorder" role.

Arguments

  • caller - Address initiating the record (must have recorder role)
  • user - Address receiving the reputation points
  • event_type - Type of event being recorded
  • points - Custom points to award

Returns

The user's new total points

Errors

  • Error::InvalidPoints - If points is 0
  • Error::PointsOverflow - If adding points would overflow
fn record_event_with_points(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    user: soroban_sdk::Address,
    event_type: EventType,
    points: u32,
) -> u32

Set a permission threshold.

Requires the "config" role.

Arguments

  • caller - Address initiating the update (must have config role)
  • threshold_type - Type of threshold to set
  • level - Required level (0-4)
fn set_permission_threshold(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    threshold_type: ThresholdType,
    level: u32,
)

Imports

WebAssembly Text (WAT) ▶