✨Browser SDK

Verify includes a Javascript SDK which handles showing a wallet connection UI, making API requests and returning results. This is the recommended way of interacting with Verify, but we also have a REST API if you want to build your own UI.

Installation

Install the SDK via NPM or by importing with a <script> tag.

Install the SDK from NPM

npm install --save @diamondhh/verify

Import the combined bundle for all supported chains

import VerifySdk from '@diamondhh/verify'

Or import a chain specific bundle (supports tree shaking)

import VerifySdk from '@diamondhh/verify/solana' // OR
import VerifySdk from '@diamondhh/verify/ethereum' // Also supports Polygon

The SDK will automatically inject the required stylesheet, no CSS import required.Import the default CSS in your <head>

Usage

Initialise the SDK

Before you can use Verify you need to set your API key. You can get an API key for free by registering on Diamond Hands Hotel.

Make a request

Now the SDK is set up you're ready to start making requests. The quickest way to get started is to read the example below and review the comments for detailed information. This example uses all available options, but only chain and contract are required.

Parameter
Required
Type
Description

chain

  • SOL

  • ETH

  • MATIC

Chain to find the contract on

contract

String

Ethereum & Polygon Contract address Solana

Candy Machine program address

network

Solana

  • mainnet

  • testnet

  • devnet

Ethereum

  • mainnet

  • goerli

  • rinkeby

Polygon

  • mainnet

  • mumbai

Network to use, defaults to mainnet

marketplace.name

  • OPENSEA

  • LOOKS_RARE

  • MAGIC_EDEN

  • SOLANART

Marketplace to fetch collection metadata from

marketplace.slug

String

Required if a marketplace name is provided and the chain is SOL

metadata.name

String

Collection name

metadata.avatarImage

URL

Avatar image (must be an absolute URL)

metadata.bannerImage

URL

Banner image (must be an absolute URL)

metadata.socials

Object[]

Social links to display. Valid options for type are WEB , TWITTER and DISCORD

data.value

String

Arbitrary data that will be included in the signed result

data.hmac

String

Recommended with data.value

SHA256 HMAC of the data, where the key is your secret key. If a HMAC is provided but invalid an error will be thrown.

Get results

res will resolve to an object with the results of the verification request once the user has completed the verification (either passing or failing). If aborted without completing, the call will throw an error.

Result

result holds a summary of the verification result.

Property
Required
Type

ownership

Boolean

Whether the wallet owns at least one NFT from the provided contract

wallet.address

String

The wallet address that was checked

wallet.verified

Boolean

Whether wallet ownership was also verified. false if you provided wallet.address to the verification request without passing a HMAC.

data.value

String

Arbitrary data that was passed to the verification request

data.verified

Boolean

true if a valid data HMAC was provided. false if a HMAC was not provided. Request will throw an error if an invalid HMAC was provided.

at

String

Unix millis timestamp of the verification

Asset

asset has some basic information about the contract verified.

Additional fields may be returned depending on the chain and contract. You should expect at least the below, but all available data will be returned (e.g family for some Solana NFTs and description if implemented by contract creator).

Property
Required
Type
Description

chain

  • SOL

  • ETH

  • MATIC

Contract chain

network

Solana

  • mainnet

  • testnet

  • devnet

Ethereum

  • mainnet

  • goerli

  • rinkeby

Polygon

  • mainnet

  • mumbai

Contract network

contract

String

Contract address

symbol

String

Symbol declared in the metadata

Tokens

tokens is an array of NFTs from the provided contract that the wallet owns. If the user owns no NFTs from the contract then this array will be empty. NFTs from other contracts are not returned (you should make another request to fetch results from multiple collections).

metadata key includes the raw token metadata, and will vary depending on the contract implementation. Other than checks to ensure reasonable data size, there is no additional processing or normalisation done.

Property
Required
Type
Description

id

String

Ethereum & Polygon Token ID Solana Address of the token

uri

URL

Source URL of off-chain metadata

metadata

Object

EIP-1155 compatible token metadata. Available properties will vary depending on the NFT and chain.

Unlockables

unlockables is an array of valid unlockables which were requested. Any unlockables which aren't found or don't match the chain/contract settings will be silently ignored.

Property
Required
Type
Description

name

String

Name of the unlockable

type

  • image

  • video

  • file

  • json

  • text

  • webhook

Type of unlockable

content

  • Object

  • String

  • URL

Image, video and file unlockables will return a pre-signed URL that can be used to access the file. JSON unlockables will return an Object. Text unlockables will return a String. Webhook unlockables will return an Object if the Content-Type header is application/json, otherwise will return a String.

createdAt

Date

Creation date

updatedAt

Date

Last modification date

error

Object

Webhook unlockables which throw an error will return an object with code and message properties (see Errors)

Verifying results

Included in the results object is a signed property. This is a JSON Web Token signed with your secret key, where the payload is the full results object excluding unlockables.

You can pass this string to your backend and verify it using any JWT library. Below is an example using the jsonwebtoken library.

Events

You can listen for events from Verify to update the state of your application.

Last updated

Was this helpful?