Broadcast Momoka Transaction
Momoka Overview
Lens Protocol is currently deployed on Polygon, an EVM-based network. All actions—such as posts, comments, mirrors, follows, and collects are transactions that are constructed, signed, and sent to be stored on the EVM machine. Unlike the EVM process, Momoka constructs the transaction, requires a signature from a wallet (that would pass the state onchain) but does not send and broadcast the actual transaction on-chain.
Instead, the transaction signature and typed data are used to create DA metadata as a transaction. This transaction is then transmitted to a DA layer containing information such as the block number and block hash when such a transaction was created upon, signed typed data, transaction signature, and other crucial details. This data is structured in a way that can be fully verified with only an archive node.
Broadcast To Momoka
In order to broadcast a transaction to Momoka, you can use broadcastDataAvailability
that handles the process for you.
Request
- id:
broadcastId
(required- This is the
id
field that is returned from the typed data calls (create*TypedData
).
- This is the
- signature :
Signature
(required)- The signed typed data.
Invocation
const result = await lensClient.transaction.broadcastOnMomoka({
id,
signature: signedTypedData,
});
mutation BroadcastOnMomoka($request: BroadcastRequest!) {
broadcastOnMomoka(request: $request) {
... on CreateMomokaPublicationResult {
id
proof
momokaId
}
... on RelayError {
__typename
reason
}
}
}
Response
{
// This is the publication ID, it is unique and can be used in all
// the same queries as before when using the publication ID to search
"id": "profileId-publicationId-DA-FIRST_8_CHARS_OF_DATA_AVAILABILTY-ID",
// The arweave txId which is the proof string you can run checks on.
"proof": "0x01",
// This is not that useful for much, but the proof itself has an ID.
"momokaId": "0x01"
}
{
"__typename": "RelayError",
"reason": "REJECTED" // RelayErrorReasons
}
Full LensClient Example
// with an authenticated instance of LensClient
// we need some typedData to sign and broadcast, here we're using creating a post as an example
const typedDataResult = await lensClient.publication.createMomokaPostTypedData({
contentURI: "your-content-uri",
});
const { id, typedData } = typedDataResult.unwrap();
// sign with the wallet
const signedTypedData = await wallet._signTypedData(
typedData.domain,
typedData.types,
typedData.value
);
const broadcastOnMomokaResult = await lensClient.transaction.broadcastOnMomoka({
id,
signature: signedTypedData,
});
const momokaRelayResult = broadcastOnMomokaResult.unwrap();
if (!isMomokaRelayResult(momokaRelayResult)) {
console.log(`Something went wrong`);
return;
}
console.log(
`Successfully broadcasted momoka transaction with id ${momokaRelayResult.id}, momokaId: ${momokaRelayResult.momokaId}, proof: ${momokaRelayResult.proof}`
);
Full GraphQL API Example
Updated about 1 month ago