{"id":13767564,"url":"https://github.com/dabit3/lens-create-publication-example","last_synced_at":"2025-11-17T15:20:17.600Z","repository":{"id":62634047,"uuid":"560944023","full_name":"dabit3/lens-create-publication-example","owner":"dabit3","description":"An example project showing how to create a publication using withSig and typed data","archived":false,"fork":false,"pushed_at":"2022-11-03T15:09:45.000Z","size":159,"stargazers_count":20,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-05T22:54:15.778Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dabit3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-02T15:48:06.000Z","updated_at":"2023-08-04T03:32:39.000Z","dependencies_parsed_at":"2022-11-04T03:40:08.663Z","dependency_job_id":null,"html_url":"https://github.com/dabit3/lens-create-publication-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabit3%2Flens-create-publication-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabit3%2Flens-create-publication-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabit3%2Flens-create-publication-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabit3%2Flens-create-publication-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dabit3","download_url":"https://codeload.github.com/dabit3/lens-create-publication-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253728796,"owners_count":21954494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T16:01:09.780Z","updated_at":"2025-11-17T15:20:17.552Z","avatar_url":"https://github.com/dabit3.png","language":"JavaScript","funding_links":[],"categories":["Learn"],"sub_categories":["Examples"],"readme":"# Posting to Lens\n\nThis is an example project that shows how to:\n\n1. Authenticate a user with the Lens API\n2. Once authenticated, publish a post to Lens using [typed data](https://eips.ethereum.org/EIPS/eip-712)\n\nThe `api.js` file has most of the helper functions needed for creating a `withSig` transaction, the GraphQL API, and the GraphQL queries and mutations.\n\n\u003e For this project to run, you must configure the Infura project ID and project secret. Check out `.example.env.local` for guidance.\n\n### Sending authenticated requests\n\nOnce authenticated, you will receive an access token.\n\nUsing this access token, you can send authenticated requests to the Lens API.\n\nUsing the Apollo GraphQL client, there are two ways to do this:\n\n1. Manually passing in headers:\n\n```javascript\nconst result = await client.mutate({\n  mutation: createPostTypedData,\n  variables: {\n    request,\n  },\n  context: {\n    headers: {\n      Authorization: `Bearer ${token}`\n    }\n  }\n})\n```\n\n2. Configuring an Apollo Link:\n\n```javascript\nimport { ApolloClient, InMemoryCache, gql, createHttpLink } from '@apollo/client'\nimport { setContext } from '@apollo/client/link/context';\n\nconst authLink = setContext((_, { headers }) =\u003e {\n  const token = window.localStorage.getItem('your-storage-key')\n  return {\n    headers: {\n      ...headers,\n      authorization: token ? `Bearer ${token}` : \"\",\n    }\n  }\n})\n\nconst httpLink = createHttpLink({\n  uri: API_URL\n})\n\nexport const client = new ApolloClient({\n  link: authLink.concat(httpLink),\n  cache: new InMemoryCache()\n})\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabit3%2Flens-create-publication-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdabit3%2Flens-create-publication-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabit3%2Flens-create-publication-example/lists"}