Legacy Collect

Learn how to collect a Lens v1 Publication.


This page is intended for those integrating dApps using the JavaScript SDK or the Lens API directly. If you're using the Lens React SDK, it automatically handles Legacy Collect, so you can skip this page.

Publications created with Lens v1 are not compatible with the new Lens v2 Open Actions. To collect a Legacy Publication, you must use a distinct feature called Legacy Collect.

However, you can still utilize Sponsored Transactions and the Signless Experience, if enabled.

Legacy Collect Criteria

You can identify a Legacy Publication by checking the openActionModule.__typename value. Any module with a name starting with Legacy indicates a Publication with a legacy collect module. To collect these, you need to use the Legacy Collect feature.

const collectable =  publication.__typename === "Mirror" ? publication.mirrorOn : publication;
switch (collectable.openActionModule.__typename) {  case "LegacyAaveFeeCollectModuleSettings":  case "LegacyERC4626FeeCollectModuleSettings":  case "LegacyFeeCollectModuleSettings":  case "LegacyLimitedFeeCollectModuleSettings":  case "LegacyLimitedTimedFeeCollectModuleSettings":  case "LegacyMultirecipientFeeCollectModuleSettings":  case "LegacyTimedFeeCollectModuleSettings":  case "LegacySimpleCollectModuleSettings":  case "LegacyFreeCollectModuleSettings":    // publication with a legacy collect module    // use Legacy Collect to collect it    return;
  case "SimpleCollectOpenActionSettings":  case "MultirecipientFeeCollectOpenActionSettings":    // use act on open action to collect it    return;
  default:    // publication is not collectable    return;}

Collect Legacy Publication

You must be authenticated with a Profile to use Legacy Collect. See Profile Login for more information.

The examples below assume that you have a client.ts module that exports a LensClient instance, already authenticated with a Profile.

Sponsored and Signless

Use this flow if the Signless Experience is enabled for the authenticated Profile.

You should use the client.publication.legacyCollect method to collect the Legacy Publication.

JS SDK
import { isRelaySuccess } from "@lens-protocol/client";
import { client } from "./client";
const result = await client.publication.legacyCollect({  on: post.id,});
// handle authentication errorsif (result.isFailure()) {  console.error(result.error); // CredentialsExpiredError or NotAuthenticatedError  process.exit(1);}
const data = result.value;
// handle relay errorsif (!isRelaySuccess(data)) {  console.error(data.reason); // failed to relay the tx  process.exit(1);}
// wait for the tx to be mined and indexedconst completion = await client.transaction.waitUntilComplete({ forTxId: data.txId });
// handle mining/indexing errorsif (completion?.status === LensTransactionStatusType.Failed) {  console.error(completion.reason); // failed to mine or index the tx  process.exit(1);}
console.log("Legacy publication collected");

Sponsored-Only

Use this flow if the Signless Experience is disabled for the authenticated Profile.

You should use the client.publication.createLegacyCollectTypedData method to collect the Legacy Publication.

import { isRelaySuccess, LensTransactionStatusType } from "@lens-protocol/client";import { Wallet } from 'ethers';
import { client } from "./client";
// the same wallet used to authenticateconst wallet = new Wallet('<private-key>');
// create the typed dataconst typedDataResult = await client.publication.createLegacyCollectTypedData({  on: post.id,});
// handle authentication errorsif (typedDataResult.isFailure()) {  console.error(typedDataResult.error); // CredentialsExpiredError or NotAuthenticatedError  process.exit(1);}
const data = typedDataResult.value;
// sign with the wallet, ethers.js in this exampleconst signature = await wallet.signTypedData(  data.typedData.domain,  data.typedData.types,  data.typedData.value,);
// broadcastconst broadcastResult = await client.transaction.broadcastOnchain({  id: data.id,  signature,});
// handle authentication errorsif (broadcastResult.isFailure()) {  console.error(broadcastResult.error); // CredentialsExpiredError or NotAuthenticatedError  process.exit(1);}
const broadcastResultValue = broadcastResult.value;
// handle relay errorsif (!isRelaySuccess(broadcastResultValue)) {  console.error(broadcastResultValue.reason);  process.exit(1);}
// wait for the tx to be mined and indexedconst completion = await client.transaction.waitUntilComplete({  forTxId: broadcastResultValue.txId});
// handle mining/indexing errorsif (completion?.status === LensTransactionStatusType.Failed) {  console.error(completion.reason);  process.exit(1);}
console.log("Legacy publication collected");

That's it—you've just learned how to collect a Legacy Publication.