Discord / Telegram bots

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.

Verifying a Discord handle

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.

Last updated