From 8ec0a8921b5b0a96289735345d5143143aa75e0e Mon Sep 17 00:00:00 2001 From: Carl Cervone <42869436+ccerv1@users.noreply.github.com> Date: Tue, 24 Sep 2024 07:07:18 -0400 Subject: [PATCH] docs: update farcaster sql --- apps/docs/docs/integrate/overview/index.mdx | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/apps/docs/docs/integrate/overview/index.mdx b/apps/docs/docs/integrate/overview/index.mdx index b91fc102..dad93809 100644 --- a/apps/docs/docs/integrate/overview/index.mdx +++ b/apps/docs/docs/integrate/overview/index.mdx @@ -332,6 +332,41 @@ GROUP BY fid, display_name ORDER BY reaction_count DESC ``` +Here's another use case, showing how to derive all the verified Ethereum addresses owned by a Farcaster user: + +```sql +WITH + profiles AS ( + SELECT + v.fid, + v.address, + p.custody_address, + JSON_VALUE(p.data, "$.username") AS username, + FROM `YOUR_PROJECT_NAME.farcaster.verifications` v + JOIN `YOUR_PROJECT_NAME.farcaster.profiles` p ON v.fid = p.fid + WHERE v.deleted_at IS NULL + ), + eth_addresses AS ( + SELECT + fid, + username, + address + FROM profiles + WHERE LENGTH(address) = 42 + UNION ALL + SELECT + fid, + username, + custody_address AS address + FROM profiles + ) +SELECT DISTINCT + fid, + username, + address +FROM eth_addresses +``` + **Remember to replace 'YOUR_PROJECT_NAME' with the name of your project in the query.** ### Lens Data