Guides

Create a quote

🚧

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 quote via Lens Profile Manager

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

Request

OnchainQuoteRequest

Invocation

const result = await client.publication.quoteOnchain({
  quoteOn: '0x123-0x456',
  contentURI: 'ipfs://Qm...', // or arweave
});
mutation QuoteOnchain($request: OnchainQuoteRequest!) {
  result: quoteOnchain(request: $request) {
    ... on RelaySuccess {
      ...RelaySuccess
    }
    ... on LensProfileManagerRelayError {
      ...LensProfileManagerRelayError
    }
  }
}

Response

RelaySuccess or LensProfileManagerRelayError


b) Create a quote using TypedData and broadcasting Onchain via the API

Request

OnchainQuoteRequest

Invocation

const resultTypedData = await client.publication.createOnchainQuoteTypedData({
  quoteOn: '0x123-0x456',
  contentURI: 'ipfs://Qm...', // or arweave
});
mutation CreateOnchainQuoteTypedData($request: OnchainQuoteRequest!, $options: TypedDataOptions) {
  result: createOnchainQuoteTypedData(request: $request, options: $options) {
    ...CreateOnchainQuoteBroadcastItemResult
  }
}

Response

CreateOnchainQuoteBroadcastItemResult

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 onchain.

See Broadcasting Onchain for more information.


Full LensClient Example

Using the Lens Profile Manager:

// the client instance must be authenticated

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

const resultValue = result.unwrap();

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

console.log(`Transaction was successfully broadcasted with txId ${resultValue.txId}`);

Using TypedData:

// the client instance must be authenticated

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

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

console.log(`Typed data: `, typedData);

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

console.log(`Broadcasting signed typed data...`);

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

const broadcastValue = broadcastResult.unwrap();

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

console.log(`Transaction was successfully broadcasted with txId ${broadcastValue.txId}`);