Guides

Create a post 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 post on Momoka via Lens Profile Manager

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

Request

MomokaPostRequest

Invocation

const result = await client.publication.postOnMomoka({
  contentURI: 'ipfs://Qm...', // or arweave
});
mutation PostOnMomoka($request: MomokaPostRequest!) {
  result: postOnMomoka(request: $request) {
    ... on CreateMomokaPublicationResult {
      ...CreateMomokaPublicationResult
    }
    ... on LensProfileManagerRelayError {
      ...LensProfileManagerRelayError
    }
  }
}

Response

CreateMomokaPublicationResult or LensProfileManagerRelayError


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

Request

MomokaPostRequest

Invocation

const resultTypedData = await client.publication.createMomokaPostTypedData({
  contentURI: 'ipfs://Qm...', // or arweave
});
mutation CreateMomokaPostTypedData($request: MomokaPostRequest!) {
  result: createMomokaPostTypedData(request: $request) {
    ...CreateMomokaPostBroadcastItemResult
  }
}

Response

CreateMomokaPostBroadcastItemResult

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.postOnMomoka({
  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.createMomokaPostTypedData({
  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);