POST /api/v1/mint/verified

Endpoint used for generation of minting parameters for listings that required verified minter address

For general information on how to generate minting parameters visit POST /api/v1/mint

This endpoint is used for generating minting parameters in case our backend needs a verified minter address. This is the case when the ENS name is listed with a whitelisting or token-gated access feature.

The request and response of this endpoint are the same ones as /api/v1/mint, the only difference is that this endpoint requires a special token to be sent so that our backend can verify that the request comes from a verified minter.

Generating the authentication token (example with TypeScript and Viem):

import axios from "axios";
import { createWalletClient, Address, http } from "viem"
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'

const namespaceBackendApi = process.env.NAMESPACE_BACKEND_API;
const wallet = privateKeyToAccount(process.env.WALLET_KEY);

const walletClient = createWalletClient({
   transport: http(),
   chain: mainnet,
   account: wallet  
});

interface TokenClaims {
    princial: Address // address of wallet that is signing the message
    nonce: string // random string that needs to be fetched from /siwe/nonce endpoint
}

const generateAuthToken = async (principal: Address): Promise<string> => {
   const nonce = await getNonce();
   const claims: TokenClaims = {
      principal,
      nonce   
   };
   const claimsJSON = JSON.stringify(claims);
   const signature = await walletClient.signMessage(
      { message: claimsJSON }
   );
   
   const base64Signature = base64(signature);
   const base64Claims = base64(claimsJSON);
   
   const authToken = `${base64Claims}.${base64Signature}`;
   
   return authToken;
}

const getNonce = (): Promise<string> => {
  return await axios.get<string>(`${namespaceBackendApi}/siwe/nonce`)
  .then(res => res.data)
}

const base64 = (value: string) => {
 return Buffer.from(value, 'base64').toString();
}

When sending the request to /api/v1/mint/verified, the generated token has to be provided as an Authorization header

{
    "headers": {
      "Authorization": "generated-token"   
    }
}

Last updated