Discord / Telegram bots
Last updated
Last updated
If you have a project using Discord or Telegram for verification features (ie: possession of specific NFTs / or permission tokens) then NFDs are an excellent way to let users get access without having to do anything other than provide their NFD name !
Users can verify their Discord and Telegram accounts via NFDs. If users perform this verification, their ID will be stored as a 'verified' property in their NFD and provide a trivial way of sign on w/ proven on-chain metadata.
Once a user has verified their Discord ID, their Discord 'snowflake' ID will be set in properties.verified.discord in the 'full' view of an NFD fetch.
To use NFDs for verification, a bot simply needs to use the users' snowflake ID and find all NFDs that have that ID as a verified discord handle. You will be able to know the Algorand accounts are all theirs, no webpage has to be popped, nor transactions to sign.
The bot should query the API (See NFDomains REST API Reference), the /nfd/v2/search?vproperty=discord&vvalue={snowflakeid} endpoint specifically (with the 'full' view), for the id of the user.
If NFD(s) are returned for that discord ID, then all the 'related' accounts of those NFDs can be examined.
These are:
Owner - the owner of the account is guaranteed and can't be impersonated.
nfdAccount - this is the account address of the NFD itself. NFDs can contain assets and this will come into play more in the future.
caAlgo[*] - the list of accounts in the caAlgo array are the accounts the user has explicitly linked to their NFD and all are accounts the user can sign for.
All of these accounts can be searched by the bot to check for ownership of membership assets (like owning a particular NFT or other membership token). If found in any of these accounts, then the discord user (which owns that NFD) can be assigned specific roles which require proof of ownership.
Because users can either sell their NFDs, or the assets which gave them access, it is suggested that bots store the discord id and periodically reassert the above search/account checks. If the user either sells their asset or perhaps links additional accounts that grant additional rights, the bot should remove or add roles as appropriate.
Search NFDs via various filters
/nfd/v2/search
name or partial match of NFD name to filter on
The parent NFD Application ID to find. Used for fetching segments of an NFD
1000000
Length of NFD
Traits of NFD
An Algorand Account address
4F5OA5OQC5TBHMCUDJWGKMUZAQE7BGWCKSJJSJEMJO5PURIFT5RW3VHNZU
^[A-Z2-7]{57}[AEIMQUY4]$
An Algorand Account address
4F5OA5OQC5TBHMCUDJWGKMUZAQE7BGWCKSJJSJEMJO5PURIFT5RW3VHNZU
^[A-Z2-7]{57}[AEIMQUY4]$
Should NFDs reserved for an account (transfers for example or unclaimed winning auctions) be excluded
The start of an NFD name, fetching multiple NFDs that have that prefix
Part of an NFD name, fetching multiple NFDs that have that substring (minimum 3 characters)
Verified property name to search on - specify value with vvalue
telegram
discord
, telegram
, twitter
, github
, email
, domain
, nostrpubkey
Value to find in the vproperty field specified with the vproperty parameter
abc123
Whether to explicitly filter on segments being locked or unlocked. Typically only valuable when filtering on unlocked
false
Whether to explicitly filter on NFD roots or segments. True to only see roots, False to only see segments.
false
Minimum price of NFD
Maximum price of NFD
Minimum price of NFD Segment in USD (cents)
Maximum price of NFD Segment in USD (cents)
Fetch NFDs that changed after the specified timestamp
1970-01-01T00:00:01Z
Return only NFDs with an expiration time at or before the specified timestamp
1970-01-01T00:00:01Z
Limit the number of results returned - max 200
Starting document in large list. Fetch 1-100 [limit 100], pass offset 100 to fetch 100-200
What to sort on
createdDesc
, timeChangedDesc
, soldDesc
, priceAsc
, priceDesc
, highestSaleDesc
, saleTypeAsc
, nameAsc
, expiresAsc
, expiresDesc
View of data to return, tiny (name, owner, caAlgo, unverifiedCaAlgo only), brief (default), or full
tiny
, thumbnail
, brief
, full
etag