provides easy-to-use APIs for enriching applications and integrating on-chain and off-chain data with Farcaster.
is an Ethereum-based messaging protocol.
Developers building with can use to enable users to seamlessly message Ethereum, ENS, Lens, and Farcaster users with XMTP-enabled addresses.
is utilized to:
check if users have enabled (required in order to receive messages)
resolve usernames to 0x Ethereum addresses and vice versa.
In this guide you will learn how to use to:
Pre-requisites
Basic knowledge of GraphQL
Get Started
JavaScript/TypeScript/Python
If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:
npm yarn pnpm pip
React
Copy npm install @airstack/airstack-react
Node
Copy npm install @airstack/node
React
Copy yarn add @airstack/airstack-react
Node
Copy yarn add @airstack/node
React
Copy pnpm install @airstack/airstack-react
Node
Copy pnpm install @airstack/node
Copy pip install airstack asyncio
Then, add the following snippets to your code:
React Node Python
Copy 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 (loading) {
return <p>Loading...</p>;
}
if (error) {
return <p>Error: {error.message}</p>;
}
// Render your component using the data returned by the query
};
Copy import { init, fetchQuery } from "@airstack/airstack-react";
init("YOUR_AIRSTACK_API_KEY");
const query = "YOUR_QUERY"; // Replace with GraphQL Query
const { data, error } = fetchQuery(query);
console.log("data:", data);
console.log("error:", error);
Copy 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())
Other Programming Languages
Check Farcaster Has XMTP Enabled
You can check if a Farcaster has XMTP enabled or not by providing either the Farcaster name or ID:
Try Demo
Code
Query Response
Copy query MyQuery {
XMTPs(input: {blockchain: ALL, filter: {owner: {_eq: "fc_fname:vbuterin"}}}) {
XMTP {
isXMTPEnabled
}
}
}
Copy {
"data": {
"XMTPs": {
"XMTP": [
{
"isXMTPEnabled": true
}
]
}
}
}
Bulk Check Farcasters Have XMTP Enabled
You can bulk check a list of Farcasters have XMTP enabled or not:
Try Demo
Code
Query Response
Copy query MyQuery {
XMTPs(input: {blockchain: ALL, filter: {owner: {_in: ["fc_fname:betashop.eth", "fc_fid:5650"]}}}) {
XMTP {
isXMTPEnabled
owner {
socials {
dappName
profileName
}
}
}
}
}
Copy {
"data": {
"XMTPs": {
"XMTP": [
{
"isXMTPEnabled": true
},
{
"isXMTPEnabled": true
}
]
}
}
}
Get all 0x addresses of Farcaster user(s)
You can resolve an array of Farcaster user(s) to their 0x addresses:
Try Demo
Code
Query Response
Copy query GetAddressesOfFarcasters {
Socials(
input: {filter: {identity: {_in: ["fc_fname:dwr.eth", "fc_fid:1"]}}, blockchain: ethereum}
) {
Social {
userAssociatedAddresses
}
}
}
Copy {
"data": {
"Socials": {
"Social": [
{
"userAssociatedAddresses": [
"0x8773442740c17c9d0f0b87022c722f9a136206ed",
"0x86924c37a93734e8611eb081238928a9d18a63c0"
]
},
{
"userAssociatedAddresses": [
"0xd7029bdea1c17493893aafe29aad69ef892b8ff2"
]
},
{
"userAssociatedAddresses": [
"0xb877f7bb52d28f06e60f557c00a56225124b357f",
"0xa14b4c95b5247199d74c5578531b4887ca5e4909",
"0xd7029bdea1c17493893aafe29aad69ef892b8ff2",
"0x74232bf61e994655592747e20bdf6fa9b9476f79"
]
}
]
}
}
}
Get all Farcasters owned by 0x address
You can resolve any 0x address to their Farcaster accounts:
Try Demo
Code
Query Response
Copy query GetFarcastersOfEthereumAddress {
Socials(
input: {filter: {identity: {_in: ["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"]}, dappName: {_eq: farcaster}}, blockchain: ethereum}
) {
Social {
profileName
userId
userAssociatedAddresses
}
}
}
Copy {
"data": {
"Socials": {
"Social": [
{
"profileName": "vitalik.eth",
"userId": "5650",
"userAssociatedAddresses": [
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
"0xadd746be46ff36f10c81d6e3ba282537f4c68077"
]
}
]
}
}
}
Developer Support
More Resources