Current repo contains vSelf smart contracts source code. It includes smart contract providing the functionality set up, mint, and distribute NFTs (SBT or transferable) here and one for community management here.
Frontend web app & API endpoints are available in this repo.
- testnet contract deployed at events_v33.sergantche.testnet
- mainnet contract deployed at v4.event.vself.near
- testnet contract deployed at communities_v6.sergantche.testnet
- mainnet contract deployed at communities_v1.sergantche_dev.near
This contract mints NFT to recipient account on successful checkin (e.g. via claim link or QR-code).
Each token is uniquely identified by a tuple <event_id>:<reward_index>, where <reward_index> is the index of the reward from the <event_id> NFT collection.
#Compile contract
yarn events:buildSet values for EVENTS_CONTRACT (account on which the contract will be deployed) and MASTER_ACCOUNT (account from which the contract subaccount will be created) in ./config/deployment.env
#Testnet contract deployment
yarn events:deploy
#Mainnet contract run
NEAR_ENV=mainnet
yarn events:deployNFT reward
struct QuestData {
qr_prefix: String,
qr_prefix_len: usize,
reward_title: String,
reward_description: String,
reward_uri: String,
}
Event data
struct EventData {
event_name: String,
event_description: String,
start_time: u64,
finish_time: u64,
quests: Vec<QuestData>,
}
Collection stats
struct EventStats {
participants: HashSet<AccountId>,
created_by: AccountId,
created_at: u64,
stopped_at: Option<u64>,
total_rewards: u64,
total_users: u64,
total_actions: u64,
}
Settings of NFT collection
struct CollectionSettings {
signin_request: bool,
transferability: bool,
limited_collection: bool,
ambassador_allowed: bool,
}
-
start_event(event_data: EventData, collection_settings: CollectionSettings)runs new event with event_data and collection_settings and returns id of created event. -
checkin(event_id: u32, username: String, request: String)checks if therequestcontains qr_prefix as a substring and starts with it. specified in one of the quests of the event with event_id. In case of success the contract mints NFT specified in the quest to the NEAR account username owner; -
stop_event(event_id: u32)sets event with event_id as inactive disallowing checkins;
-
get_ongoing_events(from_index: u64, limit: u64)returns array of tuples(event_id: u32, data: EventData, stats: EventStats)with id, data and stats of active events using pagination. That is, for an event that has not been stopped and whose finish_time has not yet arrived; -
get_ongoing_user_events(account_id: AccountId)returns an array of tuples(event_id: u32, data: EventData, stats: EventStats)with the id, data, and statistics of active events started by account account_id; -
get_event_data(event_id: u32)returns EventData for the event with id event_id; -
get_event_stats(event_id: u32)returns EventStats consisting of some statistics about the event with event_id; -
get_user_balance(event_id: u32, account_id: AccountId)returns array of boolean values corresponding to array of quests for the event with event_id. If account_id made successfull checkin for a quest then value is true and the value is false otherwise; -
get_event_actions(event_id: u32, from_index: u64, limit: u64)returns array of data about successful and unsuccessful checkins of the event with event_id with pagination (using from_index and limit); -
get_collection_settings(event_id: u32)returns collection settings for the event event_id;
This contract is responsible for creating community, on-chain managing community metadata & community members.
Currently it holds explicit list of membeship commitments for every community created.
Each user can create any number of communities under her control.
#Compile contract
yarn communities:buildSet values for COMMUNITIES_CONTRACT (account on which the contract will be deployed) and MASTER_ACCOUNT (account from which the contract subaccount will be created) in ./config/deployment.env
#Testnet run
yarn communities:deploy#Mainnet run
NEAR_ENV=mainnet
yarn communities:deployCommunity metadata
struct CommunityData {
community_owner: AccountId,
community_name: String,
community_description: String,
community_source_image: String,
}
Communities with their metadata and public & private members
struct Contract {
members_by_community: LookupMap<String, Vec<String>>,
public_members_by_community: LookupMap<String, HashMap<String, AccountId>>,
communities: UnorderedMap<String, CommunityData>
}
add_community(community_data: CommunityData)creates new community & returns the community_id.remove_community(community_id: String)delates community with community_id.add_member(community_id: String, commitment: String)adds new member with commitment in community with community_id.add_public_member(community_id: String, commitment: String, near_id: AccountId)discloses the near_id of the member with commitment.
get_community_list(from_index: usize, limit: usize)returns community_id & community metadata for each community.get_community(community_id: String)returns community metadata and its public & private members.
