Guides

Create a comment on Momoka

🚧

This request is protected by authentication

📘

Lens Profile Manager Compatible: Gasless & Signless

This action can be used through the Lens Profile Manager to enable a gasless and signless experience.

a) Create a comment on Momoka via Lens Profile Manager

If possible, using the Lens Profile Manager is the best way to create a comment. This will be a gasless and signless operation.

Request

MomokaCommentRequest

Invocation

const result = await client.publication.commentOnMomoka({
  commentOn: '0x123-0x456',
  contentURI: 'ipfs://Qm...', // or arweave
});
mutation CommentOnMomoka($request: MomokaCommentRequest!) {
  result: commentOnMomoka(request: $request) {
    ... on CreateMomokaPublicationResult {
      ...CreateMomokaPublicationResult
    }
    ... on LensProfileManagerRelayError {
      ...LensProfileManagerRelayError
    }
  }
}

Response

CreateMomokaPublicationResult or LensProfileManagerRelayError


b) Create a comment using TypedData and broadcast to Momoka via the API

Request

MomokaCommentRequest

Invocation

const typedDataResult = await lensClient.publication.createMomokaCommentTypedData({
  commentOn: '0x123-0x456',
  contentURI: 'ipfs://Qm...', // or arweave
});
mutation CreateMomokaCommentTypedData($request: MomokaCommentRequest!) {
  result: createMomokaCommentTypedData(request: $request) {
    ...CreateMomokaCommentBroadcastItemResult
  }
}

Response

CreateMomokaCommentBroadcastItemResult

Broadcasting the TypedData

Once you have the typed data for the action, you need to get the user to sign with their wallet and then broadcast it to Momoka.

See Broadcasting Momoka Transaction for more information.


Full LensClient Example

Using the Lens Profile Manager:

// the client instance must be authenticated

const result = await client.publication.commentOnMomoka({
  commentOn: '0x123-0x456',
  contentURI: 'ipfs://Qm...', // or arweave
});

const resultValue = result.unwrap();

if (!isCreateMomokaPublicationResult(resultValue)) {
  console.log(`Something went wrong`, resultValue);
  return;
}

console.log(`Transaction was successful`, resultValue);

Using TypedData:

// the client instance must be authenticated

const typedDataResult = await lensClient.publication.createMomokaCommentTypedData({
  commentOn: '0x123-0x456',
  contentURI: 'ipfs://Qm...', // or arweave
});

const { id, typedData } = typedDataResult.unwrap();

// sign with the wallet
const signedTypedData = await wallet._signTypedData(
  typedData.domain,
  typedData.types,
  typedData.value,
);

const broadcastResult = await lensClient.transaction.broadcastOnMomoka({
  id,
  signature: signedTypedData,
});

const broadcastValue = broadcastResult.unwrap();

if (!isCreateMomokaPublicationResult(broadcastValue)) {
  console.log(`Something went wrong`);
  return;
}

console.log(`Successfully broadcasted momoka transaction`, broadcastValue);