Crossmint
This document provides instructions on how to authenticate users with Dynamic and use Crossmint’s APIs to create a wallet, mint an NFT, and display the contents of the wallets.
Developer documentation
Demo of this flow : https://snapmint.demos-crossmint.com/
Dynamic Doc - https://docs.dynamic.xyz/docs/getting-started
Crossmint Doc - https://docs.crossmint.com/docs
Authenticating Users with Dynamic
The user authentication process with Dynamic for our use case consists of two essential steps: generating a One-Time Password (OTP) and submitting the OTP for verification. The following instructions show how to use Dynamic’s API for these tasks. Dynamic will register new users or return an existing user if they have gone through the registration process before. You can view user details on your Dynamic dashboard.
To begin, create an account on dynamic.xyz and retrieve your keys from the Dashboard.
Then from your Dashboard
-
Enable Email sign up.
Generating an OTP
Now, you can setup a site that takes an email address as an input and then takes an OTP as an input.
Once you have that you can start sending an OTP(One-Time-Password) to the user’s email address.
You can find the reference for this call here
Here is the curl
command that you can use to create an OTP:
The API call will return a verificationUUID
, which will be used in the subsequent step. Replace <email>
with the actual email of the user & the <environment_id>
with your environment id from your Dynamic dashboard.
Submitting OTP for authentication
Now we will need to verify the OTP sent to the user’s email address.
You can find the reference for this call here
Here is the curl
command you can use to verify the OTP that was sent to a user :
If all the details were correct this API call will return the authenticated user object along with a JWT token. Replace <verificationUUID>
with the UUID from the previous step, and <OTP>
with the OTP sent to the user’s email. You can use the JWT token to manage sessions, authorize the user, and sign in the user.
👉 Note: This flow is for server-side verification. Dynamic also provides a React SDK to perform this verification and returns a similar user object upon successful authentication. You can learn more about Dynamic’s React SDK here
Integrating with Crossmint
Generating a Wallet for Our Dynamic User
Reference : https://docs.crossmint.com/reference/create-wallet
Now that the user is authenticated via Dynamic, let’s create a wallet for them using Crossmint.
Here is the curl command to create a wallet from email address:
Replace <your_project_id>
and <your_secret_key>
with your project ID and secret key from your Crossmint dev console, and <email>
with the email of the user for whom you are creating the wallet. This API call will return a publicKey
that represents the user’s new wallet on the Polygon chain (for this example, we support multiple blockchains).
On successful wallet creation, the API response will look something like this:
👉 One you enter the email address / userid of the user our wallet API will automatically create a multi-chain MPC wallet for you.
Once a wallet is successfully generated and the user is signed in, you can use Crossmint’s APIs to do more things for your users.
Note : You’ll need these scopes enabled while creating an API for minting and wallet generation to work.
Further examples
Minting an NFT
Reference : https://docs.crossmint.com/reference/mint-nft
Now once a user is signed in, you can take these user’s to an NFT drop page and enable them to mint an NFT.
Here’s how you can mint an NFT for this user using Crossmint’s minting api
On successful Mint, the API response will look something like this:
You can now store the NFT <id>
in your database liked to this user’s wallet & in the future you can use other APIs from Crossmint to - Edit this NFT, Transfer NFT, sign a transaction from Crossmint’s wallet, create more collections or mint more NFTs …etc.
Displaying contents of a user’s wallet
Reference : https://docs.crossmint.com/reference/fetch-content-from-wallet
Now, you may want to show the user all the NFTs that their wallet holds. To do this, you can use Crossmint’s “fetch wallet contents” API. Here’s how:
Crossmint API Reference : https://docs.crossmint.com/reference
Wallet as a service doc - https://docs.crossmint.com/docs/introduction-wallets
Was this page helpful?