Collect Essence
Workflow
Collecting an essence can be implemented in just a few easy steps. What collecting an essence essentially means is that the user will mint an NFT by calling a couple of APIs.
First, data should be presented to the user in a readable format when signing from the wallet. To do that you’ll need to call the
createCollectEssenceTypedData
API that takes care of this.If you’re unfamiliar with typed data, you can read more about it here.
caution
This API requires Authorization
header with the Bearer
token. You can learn more about it here.
- Second, once you received data in a readable format, you’ll need to get the user’s signature for it. Basically, you’ll need to write a function and pass it a
message
as a param and return thesignature
that it’s necessary for the next step.
Ethers library is one option that can quickly help you write a function to get the user’s signature for a specific message. In this our case the message represents the typed data from step 1.
- Third, you’ll have to call the
relay
API that will broadcast the transaction and mint the NFT for the collected essence, you will need to put as params thetypedDataID
you received fromcreateCollectEssenceTypedData
mutation call and the user'ssignature
.
caution
This API requires Authorization
header with the Bearer
token. You can learn more about it here.
You can now verify the transaction by looking up the txHash
from the response on etherscan.io. That’s it! You’re all done!
Experiment in Sandbox
We’ve created an example that incorporates all the steps for Collect Essence. Feel free to experiment with our code in the sandbox below. This covers a couple of steps
- Login with wallet
- Collect the Essence