General Usage
The Enefits SDK is designed for anyone with a website or an app to authenticate and verify NFT ownership as a way to give access, perks, or benefits as a result of ownership. Typically the SDK is used after creating offers within Enefits.
If you're interested in implementing the server-side Enefits API, head to this documentation to learn more.
The Enefits SDK is available for the following platforms:
- Web
- Mobile (iOS, Android, React Native, and Unity)
With the Enefits SDK you can do things like the following:
- Give NFT holders access to private sales or special areas of your website or app
- Issue redeemable single-use or multiple-use coupons or vouchers
- Give early access to your content before making available to general public
In order to use the Enefits SDK you will need an Enefits account as well as an API Key.
To obtain an API Key, simply register at http://enefits.co, go to Developer in the account menu in the top right section. From there, generate an API Key and save this for all API requests as defined below. We only show this once so if you lose this API Key, you’ll have to re-generate from the Developer section.
In this documentation we refer to the API Key as {api_key}
Enefits allows brands to give perks/benefits to holders of any NFT out in the wild. However, you may decide that you want to create an offer exclusive to holders of an NFT belonging to your own collection.
Follow this guide to create an NFT collection
At the heart of Enefits is the ability to target offers to holders of NFTs. You can any combination of NFT collections to make your offer available to. For example, you may have an exclusive collection of your own that an offer is available to but also make available to holders of Bored Ape Yacht Club or Meebits NFTs.
Follow this guide to create an offer and set target NFT collections.
This step is important because it allows your website or app to verify ownership of the NFT by the holder before granting access to the offer you created in Step 2.
There are two parts to SDK integration that you’ll need to be aware of:
- Integrating the SDK so that your audience can connect their wallet to make available their public wallet address(es)
- Unlocking access to the relevant sections of your website/app based on if the offer you are querying is in fact available to the address they expose after connecting their wallet
In order to integrate the SDK, you’ll first need to generate an API Key from your account. Follow this guide to generate an API Key.
You’ll also need to know which Offer you are querying for - this is done by using the Offer ID for the offer you created in Step 2. To get your Offer ID, log into Enefits X and then click on My Offers. You’ll find the relevant Offer ID under the Offer ID column in the Offers listing.
Initialize the SDK within your website
- Provide the API Key
- Provide the Offer ID(s) you will be checking for
Prompt user to connect their wallet
- Add a “Connect Wallet” element to the site - this will allow the user to connect to an installed wallet in the browser (usually Metamask or Fortmatic)
- The wallet addresses that the user permits access to will be returned in the response
Verify offer eligibility based on NFT ownership
- Run the “checkOffers” method - no passed value will return all offers that the address is eligible for. If an offer ID is passed into checkOffers, the SDK will check specifically if the address connected is eligible for this specific offer
Run brand-specific app or website routines based on response
- Process the response of checkOffers method - based on the response, perform the routines relevant to your brand’s offer/logic. If the user is in a logged in session, you may decide to activate a premium subscription. If the user is purchasing something on your website, you may want to show an exclusive coupon code that is unlocked based on their ownership.