Create a mirror 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 mirror on Momoka via Lens Profile Manager
If possible, using the Lens Profile Manager is the best way to create a mirror. This will be a gasless and signless operation.
Request
Invocation
const result = await client.publication.mirrorOnMomoka({
mirrorOn: '0x123-0x456',
});
mutation MirrorOnMomoka($request: MomokaMirrorRequest!) {
result: mirrorOnMomoka(request: $request) {
... on CreateMomokaPublicationResult {
...CreateMomokaPublicationResult
}
... on LensProfileManagerRelayError {
...LensProfileManagerRelayError
}
}
}
Response
CreateMomokaPublicationResult or LensProfileManagerRelayError
b) Create a mirror using TypedData and broadcast to Momoka via the API
Request
Invocation
const typedDataResult = await lensClient.publication.createMomokaMirrorTypedData({
mirrorOn: '0x123-0x456',
});
mutation CreateMomokaMirrorTypedData($request: MomokaMirrorRequest!) {
result: createMomokaMirrorTypedData(request: $request) {
...CreateMomokaMirrorBroadcastItemResult
}
}
Response
CreateMomokaMirrorBroadcastItemResult
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.mirrorOnMomoka({
mirrorOn: '0x123-0x456',
});
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.createMomokaMirrorTypedData({
mirrorOn: '0x123-0x456',
});
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);
Updated about 1 month ago