Examples

Examples and code snippets to get you started.

Use when verifying ownership of an ERC-721 NFT.
Use when verifying ownership of ERC-20 tokens.

Overview

  1. Add a Verify with NFT or Verify with token button to your page with the code snippet above.

  2. Create a backend endpoint to redirect users to after connecting with their wallet. The redirect_uri value in the snippet should be set to this URL.

  3. Once connected, users will be navigated to <redirect_uri>?code=<authCode>. This endpoint should send a POSTrequest to https://connect.inloop.to/api/v1/oauth/token with JSON body {code: <authCode>}. Remember to set an Authorization: Bearer <api_key> header.

  4. The response should be {user_token: <userToken>}. Query the list of NFT or ERC-20 tokens owned by the user by sending a GET request to https://connect.inloop.to/api/v1/users/:user_token/tokens, replacing :user_token with the <userToken>. Make sure to specify the NFTs or tokens you are looking for in your InLoop Connect dashboard!

  5. The response should be a JSON structure like the one below. You're pretty much done! Now you can grant your users benefits associated with the tokens or NFTs they own.

Code Samples

See a complete, working repo with React.js and Express.js at https://github.com/inloop-to/inloop-example.

Client-side - React example:

Server-side - Node.js example:

Last updated