๐Our Contract
Our sybil contract
Deployed contracts can be found at
Mainnet v1.nadabot.near
Staging v1.staging.nadabot.near
Testnet v1.nadabot.testnet
Our contract is at https://github.com/PotLock/core/tree/main/contracts/sybil
Purpose
Provides registry for sybil resistance providers (e.g. i-am-human, wormhole, others).
Allows users to collect stamps indicating their verification with registered providers.
Abstracts away individual sybil resistance providers/solutions to provide a single contract to call
is_human(customizable parameters coming soon)
Contract Structure
General Types
Contract
pub struct Contract {
contract_source_metadata: LazyOption<VersionedContractSourceMetadata>,
owner: AccountId,
admins: UnorderedSet<AccountId>,
providers_by_id: UnorderedMap<ProviderId, VersionedProvider>,
pending_provider_ids: UnorderedSet<ProviderId>,
active_provider_ids: UnorderedSet<ProviderId>,
deactivated_provider_ids: UnorderedSet<ProviderId>,
default_provider_ids: UnorderedSet<ProviderId>,
default_human_threshold: u32,
// MAPPINGS
// Stores all Stamp records, versioned for easy upgradeability
stamps_by_id: UnorderedMap<StampId, VersionedStamp>,
// Enables fetching of all stamps for a user
provider_ids_for_user: LookupMap<AccountId, UnorderedSet<ProviderId>>,
// Enables fetching of all users with given stamp (provider ID)
user_ids_for_provider: LookupMap<ProviderId, UnorderedSet<AccountId>>,
// Enables fetching of providers that a user has submitted (e.g. if user has submitted one malicious provider, they are likely to submit more and you'll want to be able to fetch these or filter them out of results)
provider_ids_for_submitter: LookupMap<AccountId, UnorderedSet<ProviderId>>,
}
/// Ephemeral-only
pub struct Config {
pub owner: AccountId,
pub admins: Vec<AccountId>,
pub default_provider_ids: Vec<ProviderId>,
pub default_human_threshold: u32,
pub pending_provider_count: u64, // may want to change these to U64 (string) to avoid JSON overflow, but this is highly unlikely. Easy to change later since this is ephemeral.
pub active_provider_count: u64,
pub deactivated_provider_count: u64,
}Providers
NB: Providers are stored by their ID, which is a concatenation of the contract ID + method name, e.g. "iamhuman.near:is_human"
Stamps
A stamp is the verification of a user against a given sybil provider.
Constants & Input Validation
Contract Source Metadata
NB: Below implemented as per NEP 0330 (https://github.com/near/NEPs/blob/master/neps/nep-0330.md), with addition of commit_hash
Methods
Write Methods
NB: ALL privileged write methods (those beginning with admin_* or owner_*) require an attached deposit of at least one yoctoNEAR, for security purposes.
Read Methods
Events
set_source_metadata
set_source_metadataIndicates that ContractSourceMetadata object has been set/updated.
Example:
add_provider
add_providerIndicates that a new provider has been added.
Example:
update_provider
update_providerIndicates that an existing provider has been updated.
Example:
Last updated