Help & Support

Fetch Sponsorship

This guide will show you how to fetch Sponsorship data in different ways.

Lens Sponsorship data has a rich structure that includes the following information:

  • Addresses of the primitive contract

  • Sponsorship Metadata content

  • Time of creation

  • Owner of the Sponsorship

  • Information about status of the sponsorship (pause or unpause)

To illustrate how to fetch sponsorships, we will use the following fragments:

fragment Sponsorship on Sponsorship {  __typename  address  isPaused  allowsLensAccess  createdAt  metadata {    ...SponsorshipMetadata  }  limits {    __typename    global {      ...SponsorshipRateLimit    }    user {      ...SponsorshipRateLimit    }  }  owner}

Get a Sponsorship

Use the fetchSponsorship action to fetch a single Sponsorship by address or by transaction hash.

import { evmAddress } from "@lens-protocol/client";import { fetchSponsorship } from "@lens-protocol/client/actions";
import { client } from "./client";
const result = await fetchSponsorship(client, {  address: evmAddress("0x1234…"),});
if (result.isErr()) {  return console.error(result.error);}
const sponsorship = result.value;

List Sponsorships

Use the paginated fetchSponsorships action to fetch a list of Sponsorships based on the provided filters.

import { evmAddress } from "@lens-protocol/client";import { fetchSponsorships } from "@lens-protocol/client/actions";
import { client } from "./client";
const posts = await fetchSponsorships(client, {  filter: {    managedBy: {      address: evmAddress("0x1234…"),    },  },});
if (result.isErr()) {  return console.error(result.error);}
// items: Array<Sponsorship>const { items, pageInfo } = result.value;

See the Pagination guide for more information on how to handle paginated results.