Subscribe
Workflow
Subscribing to a profile can be implemented in just a few easy steps. What subscribing to a profile 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
createSubscribeTypedData
API that takes care of this.If you’re unfamiliar with typed data, you can read more about it here.
- Second, once you received data in a readable format, you’ll need to get the user’s signature (
eth_signTypedData_v4
) for it. Basically, you’ll need to write a function and pass it amessage
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 subscribe NFT.
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 Subscribe to a profile. Feel free to experiment with our code in the sandbox below. This covers a couple of steps
- Login with wallet
- Subscribe to a profile