Skip to main content
Version: V2

Collect a post

In this section you'll learn how to implement the Collect Essence feature. Previously you've learned that creating a post means registering an essence, but the process of minting and transferring the NFT is actually executed when a user collects the post.

GraphQL mutations

To collect an essence, meaning to collect a post, is a two step process and requires two GraphQL mutations: CreateCollectEssenceTypedData and Relay.

  1. CreateCollectEssenceTypedData is used to present data to the user in a readable format:
import { gql } from "@apollo/client";

mutation CreateCollectEssenceTypedData(
$input: CreateCollectEssenceTypedDataInput!
) {
createCollectEssenceTypedData(input: $input) {
typedData {
  1. Relay is responsible for broadcasting the transaction, minting and transferring the NFT:
import { gql } from "@apollo/client";

export const RELAY = gql`
mutation Relay($input: RelayInput!) {
relay(input: $input) {
  1. RelayActionStatus is used to get the relaying status:
import { gql } from "@apollo/client";

export const RELAY_ACTION_STATUS = gql`
query RelayActionStatus($relayActionId: ID!) {
relayActionStatus(relayActionId: $relayActionId) {
... on RelayActionStatusResult {
... on RelayActionError {
... on RelayActionQueued {

Collect a Post

Now that you set up the APIs required, you can implement the Collect feature. The approach is almost exactly the same as it was for Subscribe to Profile:

  1. Get data in a readable format and the typedDataID for it;
  2. Get the user to sign the message data and get its signature;
  3. Call the relay and pass it the typedDataID and signature;
/* Create typed data in a readable format */
const typedDataResult = await createCollectEssenceTypedData({
variables: {
input: {
collector: account,
profileID: profileID,
essenceID: essenceID,

const typedData =;
const message =;
const typedDataID =;

/* Get the signature for the message signed with the wallet */
const params = [account, message];
const method = "eth_signTypedData_v4";
const signature = await signer.provider.send(method, params);

/* Call the relay to broadcast the transaction */
const relayResult = await relay({
variables: {
input: {
typedDataID: typedDataID,
signature: signature,
const txHash =;

If the collect process was successful, you can verify the transaction hash on

transaction hash

You can also view the NFT when a user collects a post on You'll notice that the image for the NFT and all other details about it correspond to the details passed to the Metadata Schema fields (e.g. image_data, name, description, etc).

nft essence

Next up you will dive deep into middlewares and learn how to set them. Let's start with Middleware for Subscribe.

Designed by