SBT Gating

All the SBTs are being recorded in a smart-contract called Registry. There are two ways to obtain information about the SBTs, either by directly calling the Registry or by using the Pikes Peak SBT Indexer.

The Registry

The smart contract provides methods to make the querying easy. The contracts are deployed here https://github.com/near-ndc/i-am-human#deployed-contracts. There are no limitations on who is allowed to query the token data. The following methods can be used:

  • sbt

  • sbt_supply

  • sbt_supply_by_class

  • sbt_supply_by_owner

  • sbt_tokens

  • sbt_tokens_by_owner

Additionaly we can check whether a given account has been banned by the registry calling is_banned method. For more details on the parameters and the return values of the methods refer to https://github.com/near-ndc/i-am-human/blob/2e7b8ef746cc5b8e45e7680c8c464f54287585c7/contracts/registry/src/registry.rs#L17.

Pikespeak SBT Indexer

The alternative method to get SBT token information is by using the Pikespeak indexer. For individual queries, (details about specific TokenID) a (issuer, token_id) is used. However for dapp queries we usually need to check if a user (or a set of users) have tokens from a specific issuer, isser+class_id or subset of issuers+class_id

Queries

Note: The query code is only for example. We will use the API as long as it works for the use cases presented below.

  • Show all SBTs for a given user, filter by issuer and/or class_id

    • sbt_by_owner(holder, issuer, Optional<class_id>, with_expired: Optional<with_expired>): []OwnedSBT -> returns all token data If with_expired if is set to false then all tokens are returned. Returns list of pairs: (Contract address, list of token IDs). Otherwise (if set to true, or None), only non expired tokens should be returned.

  • Check if a user has token:

    • check_valid_sbt(holder, issuer, class_id): bool -> returns true if he has a non expired token.

  • Check which set of users have token

    • check_and_filter([]holders, issuer, class_id): []holders -> returns a subset of holders who have a token, that are not expired, matching the criteria.

Future queries

  • Check if a user has token matching more complex criteria:

type Criteria {

filter: [](issuer, class_id) // list of pairs

min_subset: uint // minimum amount of tokens matching the filter

}

For additional questions on Pikespeak Indexer, please reach out to info@pikespeak.ai.

Last updated