Contract 4e74c4227bb16287e3ec5e263665f32362fb68fdb7217209b76ec99509d157c9

← Back to Index 📥 Download WASM

Meta

rssdkver 21.7.7#5da789c50b18a4c2be53394138212fed56f0dfc4
rsver 1.81.0

Instances

  • CA62NUE7V5ZH3WDWMHDGZ2TNATJD5DYSMCBXZW77KXANKHQFMJ6G25KF
  • CAE4MGVNVHHEVBTNO3ROHGKYLDWZFLQM65W6CVXT237EFOGBCQDO3IT4
  • CAMIBWWHGYUQZ5VYVHDAZOYEDCXUTVYWKVUESDJSZM5OZRWCOMHXVFG5
  • CAP4UO6NFZRQRR5OGIMDLUBBN7EYDTXKX4RDU6CYSLGSCEZ27YLCHKH2
  • CAQKLPM7QHVMFME4WNVQWQXG43J5DG6HKXUWHDFSAVJK7EC7I5GPML4E
  • CAR56PK3WRIQ5SDKW7AEUD5QKHG7XXGE6WHJ7ZL54US6MQOI5UOMX43Y
  • CARBUPTUZEVE2PN5AC6H2RPITSFHQRSRFBW6OBDKDCEMUQGGWH5LY44U
  • CATCIK5IELUQIN3BBNVDLCL2WI7FGVS63E23DXSV6QKHFXSCJNKUMSNP
  • CB74MZMMS6AYRDSDHJA2V3IVHFH2JR5GFA3HM4UOYL46QK46JQ5AIZT6
  • CBAUWIO3XZ6VN7TR6CSSNCWHK5MBS5P62ZZA2D3NXU3BOCWSYBARUQLD
  • CBAZI4JV5JQKIFJ3DJWK4XHHZYAXBD47FMEBYRCW2VJGMZGZ6PNXN4AE
  • CBBCXCA7RK3HKPGENLYUBBUE47OID7S7FYBQFVHXHIRUBLCSFFX53A7L
  • CBF7TDAF36I3DVI5VMFPJEVEG6TXTK3WYCRGN4W4J4STSKQGCFCCRHP5
  • CBMUSVFRZZ3ASK6CMXWOJ6GEYVWPWSURZ2KYCQETZH463QOY4G4VPZID
  • CBMYYIXFFBO5AUHDJPGXCZUPPZGJFSSJ7T3NLOR5HYWAJIAMRZZX3QRJ
  • CBRFPW27L345CRLAJ4PQAXHVFIOWFU5EQJA26LKULYWFWODNE5P2OXF5
  • CBSTPM3F2Q3WPXZMILBJNMBZQVS3C6I7NIG2SKD5GFBJTL4HIDFTBQFU
  • CC2GHLFXRPCEFE6ON3SDRFDCZNZX3BDT75VMKCN66TPX4GEZ7K6SG5H5
  • CC3V4SL3LIEZGTXVMPRV25WPWLFDXIXFPW7BOROXLKFNTAX6YT4WEIUS
  • CC7EJWWN3USC6NS7EIPYB5I5ACWSILBMWDPWT3A4N7KO2GZJYDVJCNFH
  • CCAG6FKWS4TXUDDSZ2WZAKKXZO7EFGRSNKTYI2E3YD53WK4PAMG2LACZ
  • CCHONP5S6TXEQ7THXGHN4DIK3IJX3MIZGOLQE7ENEVAJQ4JSTEYWTBY3
  • CCQNXMT35YWAROXMV2LYXI6Q3JEC67EJTWFDKUEPSODHZRXDGYPZRWM6
  • CCR7LLCIVL3DD3HF7GTS4LRMNQOXHYRLMAKUQS3FWCTVDIMOJRULBLPZ
  • CCTO24E4NGKGUQX3LPHZO2TKPFLTM72WUKXYC6EO2QY2QGOK7RHBFTTS
  • CD2KOA7UNTQYTOALE5TN2C6IOCFKHWDB7G7EX5MGUUTSAMEUFNZTBQOJ
  • CD5XQSL3UL53V5QUTSYVGT5XFCSVSEAANJSKEKWDCZ27JNLUFT4IPH4U
  • CDK7XSXCFGVUNPQDRNDW3XRX4HXX6YSOSGWRBLE2D2KEYYUIW7ZTZBGC
  • CDNKGQK376JK2ODTU4MGDC7RCXVYYRUU62R75S25Q3ZXPOWVEJA2RZOM
  • CDU7PFYXZ3OTUUBG33EP2WTK6YQC2FNGUEVVAEUB2UNGWWMTHC6NSXCS
  • CDVPJFQK33ZKKG57BQF5UGYVGBFSZEEE33DGPQDVAGBO55JTVQ557JTP

Interface

Contract constructor

Arguments

  • env - The Soroban environment
  • scorer_creator - The address of the contract creator who will be the initial manager
  • scorer_badges - The initial set of badges for the contract
  • name - The name of the scorer
  • description - The description of the scorer
  • icon - The icon URL or identifier for the scorer

Panics

  • When the contract is already initialized
  • When any of the required string arguments are empty
  • When the scorer_creator fails authentication
fn initialize(
    env: soroban_sdk::Env,
    scorer_creator: soroban_sdk::Address,
    scorer_badges: soroban_sdk::Map,
    name: soroban_sdk::String,
    description: soroban_sdk::String,
    icon: soroban_sdk::String,
)

Returns the current version of the contract

Returns

  • u32 - The version number (currently 1)
fn contract_version(env: soroban_sdk::Env) -> u32

Upgrades the contract's WASM code to a new version

Arguments

  • env - The environment object providing access to the contract's storage
  • new_wasm_hash - The hash of the new WASM code to upgrade to (32 bytes)

Authorization

  • Only the contract admin (scorer_creator) can perform the upgrade

Panics

  • If the caller is not the admin
  • If the admin address cannot be found in storage
fn upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)

Adds a new manager to the contract

Arguments

  • env - The environment object providing access to the contract's storage
  • sender - The address of the account attempting to add the manager
  • new_manager - The address of the new manager to be added

Panics

  • If the sender is not the scorer creator (Error::Unauthorized)
  • If the manager already exists (Error::ManagerAlreadyExists)
fn add_manager(
    env: soroban_sdk::Env,
    sender: soroban_sdk::Address,
    new_manager: soroban_sdk::Address,
)

Removes a manager from the contract

Arguments

  • env - The environment object providing access to the contract's storage
  • sender - The address of the account attempting to remove the manager
  • manager_to_remove - The address of the manager to be removed

Panics

  • If the sender is not the scorer creator (Error::Unauthorized)
  • If the manager does not exist (Error::ManagerNotFound)
fn remove_manager(
    env: soroban_sdk::Env,
    sender: soroban_sdk::Address,
    manager_to_remove: soroban_sdk::Address,
)

Adds a new user to the contract's user registry

Arguments

  • env - The environment object providing access to the contract's storage
  • user - The address of the user to be added

Authorization

  • Requires authorization from the user being added

Panics

  • If the user already exists and is active (Error::UserAlreadyExist)
fn add_user(env: soroban_sdk::Env, user: soroban_sdk::Address)

Removes a user from the contract's user registry

Arguments

  • env - The environment object providing access to the contract's storage
  • user - The address of the user to be removed

Authorization

  • Requires authorization from the user

Panics

  • If the user does not exist or is already inactive (Error::UserDoesNotExist)
fn remove_user(env: soroban_sdk::Env, user: soroban_sdk::Address)

Retrieves the complete map of users and their status

Arguments

  • env - The environment object providing access to the contract's storage

Returns

  • Map<Address, bool> - A map where:
  • Key: User's address
  • Value: User's status (true = active, false = inactive)
fn get_users(env: soroban_sdk::Env) -> soroban_sdk::Map

Retrieves all scorer badges from the contract's storage

Arguments

  • env - The environment object providing access to the contract's storage

Returns

  • Map<BadgeId, u32> - A map where:
  • Key: Badge ID (BadgeId struct)
  • Value: Badge score value
fn get_badges(env: soroban_sdk::Env) -> soroban_sdk::Map

Retrieves all the managers from the contract.

Arguments

  • env - The environment object providing access to the contract's storage

Returns

  • Vec<Address> - A vector of all manager addresses

Panics

  • When the managers vector cannot be found in storage (Error::ManagersNotFound)
fn get_managers(env: soroban_sdk::Env) -> soroban_sdk::Vec

Retrieves the address of the contract creator.

Arguments

  • env - The environment object providing access to the contract's storage

Returns

  • Address - The address of the scorer creator

Panics

  • When the creator's address is not found in storage (Error::ScorerCreatorDoesNotExist)
fn get_contract_owner(env: soroban_sdk::Env) -> soroban_sdk::Address

Adds a new badge to the contract

Arguments

  • env - The environment object providing access to the contract's storage
  • sender - The address of the account attempting to add the badge
  • name - The name of the badge
  • issuer - The issuer of the badge
  • score - The score value of the badge

Panics

  • If the sender is not a manager (Error::Unauthorized)
  • If a badge with the given name and issuer already exists (Error::BadgeAlreadyExists)
  • If the badge name is empty (Error::EmptyArg)
  • If the badge score is invalid (greater than 10000) (Error::InvalidScoreRange)
fn add_badge(
    env: soroban_sdk::Env,
    sender: soroban_sdk::Address,
    name: soroban_sdk::String,
    issuer: soroban_sdk::Address,
    score: u32,
)

Removes a badge from the contract

Arguments

  • env - The environment object providing access to the contract's storage
  • sender - The address of the account attempting to remove the badge
  • name - The name of the badge to remove
  • issuer - The issuer of the badge to remove

Panics

  • If the sender is not a manager (Error::Unauthorized)
  • If the badge with the given name and issuer doesn't exist (Error::BadgeNotFound)
fn remove_badge(
    env: soroban_sdk::Env,
    sender: soroban_sdk::Address,
    name: soroban_sdk::String,
    issuer: soroban_sdk::Address,
)

Retrieves contract metadata (name, description, icon)

Arguments

  • env - The environment object providing access to the contract's storage

Returns

  • (String, String, String) - A tuple containing:
  • name: Contract name
  • description: Contract description
  • icon: Contract icon
fn get_metadata(
    env: soroban_sdk::Env,
) -> (soroban_sdk::String, soroban_sdk::String, soroban_sdk::String)

Imports

WebAssembly Text (WAT) ▶