description | layout | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn how to resolve Lens profiles to 0x address, ENS, Farcaster, and XMTP and Reverse Resolution. |
|
Airstack provides easy-to-use APIs for enriching Lens applications and integrating on-chain and off-chain data with Lens.
In this guide you will learn how to use Airstack to:
- Get All 0x addresses of Lens profile(s)
- Get all ENS domains owned by Lens profile(s)
- Get All Web3 Social Accounts (Lens, Farcaster) owned by 0x address or ENS
- Get Farcaster of Lens Profile(s)
- Check If XMTP is Enabled for Lens profile(s)
- An Airstack account
- Basic knowledge of GraphQL
JavaScript/TypeScript/Python
If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:
{% tabs %} {% tab title="npm" %} React
npm install @airstack/airstack-react
Node
npm install @airstack/node
{% endtab %}
{% tab title="yarn" %} React
yarn add @airstack/airstack-react
Node
yarn add @airstack/node
{% endtab %}
{% tab title="pnpm" %} React
pnpm install @airstack/airstack-react
Node
pnpm install @airstack/node
{% endtab %}
{% tab title="pip" %}
pip install airstack
{% endtab %} {% endtabs %}
Then, add the following snippets to your code:
{% tabs %} {% tab title="React" %}
import { init, useQuery } from "@airstack/airstack-react";
init("YOUR_AIRSTACK_API_KEY");
const query = `YOUR_QUERY`; // Replace with GraphQL Query
const Component = () => {
const { data, loading, error } = useQuery(query);
if (data) {
return <p>Data: {JSON.stringify(data)}</p>;
}
if (loading) {
return <p>Loading...</p>;
}
if (error) {
return <p>Error: {error.message}</p>;
}
};
{% endtab %}
{% tab title="Node" %}
import { init, fetchQuery } from "@airstack/node";
init("YOUR_AIRSTACK_API_KEY");
const query = `YOUR_QUERY`; // Replace with GraphQL Query
const { data, error } = await fetchQuery(query);
console.log("data:", data);
console.log("error:", error);
{% endtab %}
{% tab title="Python" %}
import asyncio
from airstack.execute_query import AirstackClient
api_client = AirstackClient(api_key="YOUR_AIRSTACK_API_KEY")
query = """YOUR_QUERY""" # Replace with GraphQL Query
async def main():
execute_query_client = api_client.create_execute_query_object(
query=query)
query_response = await execute_query_client.execute_query()
print(query_response.data)
asyncio.run(main())
{% endtab %} {% endtabs %}
Other Programming Languages
To access the Airstack APIs in other languages, you can use https://api.airstack.xyz/gql as your GraphQL endpoint.
🤖 AI Natural Language
Airstack provides an AI solution for you to build GraphQL queries to fulfill your use case easily. You can find the AI prompt of each query in the demo's caption or title for yourself to try.
Airstack AI (Demo)
You can resolve an array of Lens profile(s) to their 0x addresses:
{% embed url="https://app.airstack.xyz/DTyOZg/UEnpGZrGhp" %} Show 0x addresses of lens/@nader and Lens profile id 0x0187b3 {% endembed %}
{% tabs %} {% tab title="Query" %}
query GetAddressesOfLens {
Socials(
input: {
filter: {
identity: { _in: ["lens/@nader", "lens_id:0x0187b3"] }
dappName: { _eq: lens }
}
blockchain: ethereum
}
) {
Social {
profileName
profileTokenId
profileTokenIdHex
userAssociatedAddresses
}
}
}
{% endtab %}
{% tab title="Response" %}
{
"data": {
"Socials": {
"Social": [
{
"profileName": "lens/@nader",
"profileTokenId": "10402",
"profileTokenIdHex": "0x028a2",
"userAssociatedAddresses": [
"0xb2ebc9b3a788afb1e942ed65b59e9e49a1ee500d"
]
},
{
"profileName": "lens/@vitalik",
"profileTokenId": "100275",
"profileTokenIdHex": "0x0187b3",
"userAssociatedAddresses": [
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
]
}
]
}
}
}
{% endtab %} {% endtabs %}
You can resolve an array of Lens profile(s) to their ENS domains:
{% embed url="https://app.airstack.xyz/query/UEnpGZrGhp" %} Show all ENS domains owned by lens/@bradorbradley and lens profile id 0x0187b3 {% endembed %}
{% tabs %} {% tab title="Query" %}
query GetENSOfLens {
Domains(
input: {
filter: { owner: { _in: ["lens/@bradorbradley", "lens_id:0x0187b3"] } }
blockchain: ethereum
}
) {
Domain {
name
}
}
}
{% endtab %}
{% tab title="Response" %}
{
"data": {
"Domains": {
"Domain": [
{
"name": "vitalik.eth"
},
{
"name": "bradorbradley.eth"
}
]
}
}
}
{% endtab %} {% endtabs %}
You can resolve any 0x address or ENS to their web3 socials, which comprise of Lens and Farcaster:
{% embed url="https://app.airstack.xyz/query/IWRDgNkqlQ" %} Show web3 socials (Lens, Farcaster) owned by bradorbradley.eth and 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 {% endembed %}
{% tabs %} {% tab title="Query" %}
query GetWeb3SocialsOfLens {
Socials(
input: {
filter: {
identity: {
_in: [
"bradorbradley.eth"
"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
]
}
}
blockchain: ethereum
}
) {
Social {
dappName
profileName
profileTokenId
profileTokenIdHex
userId
userAssociatedAddresses
}
}
}
{% endtab %}
{% tab title="Response" %}
{
"data": {
"Socials": {
"Social": [
{
"dappName": "lens",
"profileName": "lens/@westlakevillage",
"profileTokenId": "99755",
"profileTokenIdHex": "0x0185ab",
"userId": "0x8ec94086a724cbec4d37097b8792ce99cadcd520",
"userAssociatedAddresses": [
"0x8ec94086a724cbec4d37097b8792ce99cadcd520"
]
},
{
"dappName": "farcaster",
"profileName": "vitalik.eth",
"profileTokenId": "53546877787533711135172528420529478392632952428887988304966222706809455509504",
"profileTokenIdHex": "0x0766275746572696e000000000000000000000000000000000000000000000000",
"userId": "5650",
"userAssociatedAddresses": [
"0xadd746be46ff36f10c81d6e3ba282537f4c68077",
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
]
},
{
"dappName": "lens",
"profileName": "lens/@brad",
"profileTokenId": "116598",
"profileTokenIdHex": "0x01c776",
"userId": "0x8ec94086a724cbec4d37097b8792ce99cadcd520",
"userAssociatedAddresses": [
"0x8ec94086a724cbec4d37097b8792ce99cadcd520"
]
},
{
"dappName": "lens",
"profileName": "lens/@bradorbradley",
"profileTokenId": "36",
"profileTokenIdHex": "0x024",
"userId": "0x8ec94086a724cbec4d37097b8792ce99cadcd520",
"userAssociatedAddresses": [
"0x8ec94086a724cbec4d37097b8792ce99cadcd520"
]
},
{
"dappName": "lens",
"profileName": "lens/@vitalik",
"profileTokenId": "100275",
"profileTokenIdHex": "0x0187b3",
"userId": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
"userAssociatedAddresses": [
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
]
},
{
"dappName": "lens",
"profileName": "lens/@hanimourra",
"profileTokenId": "116239",
"profileTokenIdHex": "0x01c60f",
"userId": "0x8ec94086a724cbec4d37097b8792ce99cadcd520",
"userAssociatedAddresses": [
"0x8ec94086a724cbec4d37097b8792ce99cadcd520"
]
}
]
}
}
}
{% endtab %} {% endtabs %}
You can resolve an array of Lens profile(s) to their Farcaster name and ID, if any:
{% embed url="https://app.airstack.xyz/query/Z1f9IjxWEg" %} Show Farcasters owned by lens/@betashop9 and lens profile id 0x0187b3 {% endembed %}
{% tabs %} {% tab title="Query" %}
query GetFarcastersOfLens {
Socials(
input: {
filter: {
identity: { _in: ["lens/@betashop9", "lens_id:0x0187b3"] }
dappName: { _eq: farcaster }
}
blockchain: ethereum
}
) {
Social {
profileName
userId
userAssociatedAddresses
}
}
}
{% endtab %}
{% tab title="Response" %}
{
"data": {
"Socials": {
"Social": [
{
"profileName": "betashop.eth",
"userId": "602",
"userAssociatedAddresses": [
"0x66bd69c7064d35d146ca78e6b186e57679fba249",
"0xeaf55242a90bb3289db8184772b0b98562053559"
]
},
{
"profileName": "vitalik.eth",
"userId": "5650",
"userAssociatedAddresses": [
"0xadd746be46ff36f10c81d6e3ba282537f4c68077",
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
]
}
]
}
}
}
{% endtab %} {% endtabs %}
You can check if an array of Lens profile(s) have their XMTP enabled or not:
{% embed url="https://app.airstack.xyz/query/Jj3kxBbxP3" %} Show if XMTP is enabled for lens/@stani and Lens profile id 0x0187b3 {% endembed %}
{% tabs %} {% tab title="Query" %}
query GetLensOfFarcasters {
XMTPs(
input: {
blockchain: ALL
filter: { owner: { _in: ["lens/@stani", "lens_id:0x0187b3"] } }
}
) {
XMTP {
isXMTPEnabled
owner {
socials(input: { filter: { dappName: { _eq: lens } } }) {
profileName
profileTokenId
profileTokenIdHex
userAssociatedAddresses
}
}
}
}
}
{% endtab %}
{% tab title="Response" %}
{
"data": {
"XMTPs": {
"XMTP": [
{
"isXMTPEnabled": true,
"owner": {
"socials": [
{
"profileName": "lens/@stani",
"profileTokenId": "5",
"profileTokenIdHex": "0x05",
"userAssociatedAddresses": [
"0x7241dddec3a6af367882eaf9651b87e1c7549dff"
]
},
{
"profileName": "lens/@lilgho",
"profileTokenId": "110056",
"profileTokenIdHex": "0x01ade8",
"userAssociatedAddresses": [
"0x7241dddec3a6af367882eaf9651b87e1c7549dff"
]
},
{
"profileName": "lens/@lensofficial",
"profileTokenId": "47319",
"profileTokenIdHex": "0x0b8d7",
"userAssociatedAddresses": [
"0x7241dddec3a6af367882eaf9651b87e1c7549dff"
]
}
]
}
},
{
"isXMTPEnabled": true,
"owner": {
"socials": [
{
"profileName": "lens/@vitalik",
"profileTokenId": "100275",
"profileTokenIdHex": "0x0187b3",
"userAssociatedAddresses": [
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
]
}
]
}
}
]
}
}
}
{% endtab %} {% endtabs %}
If you have any questions or need help regarding resolving identities for Lens profile(s), please join our Airstack's Telegram group.