Skip to content

Instantly share code, notes, and snippets.

View manan19's full-sized avatar
🪐
Identity. Network. Content.

Manan manan19

🪐
Identity. Network. Content.
View GitHub Profile
@manan19
manan19 / get-casts-example.js
Last active November 10, 2023 00:53
Sample code to get casts by fid from your Neynar-hosted Farcaster hub using a secure client
const { getSSLHubRpcClient } = require('@farcaster/hub-nodejs');
const getCastsByFid = async (hubRpcEndpoint, fid) => {
let client = getSSLHubRpcClient(hubRpcEndpoint);
client.$.waitForReady(Date.now() + 2000, async (e) => {
if (e) {
console.error(`Failed to connect to ${hubRpcEndpoint}`);
} else {
console.log(`Connected to ${hubRpcEndpoint}`);
@manan19
manan19 / signed_key.ts
Last active September 24, 2025 14:51
Generating an ECDSA signature
/****
Note - This snippet will not be maintained / updated as of Nov 29, 2023.
Please check out the to generate signers with Neynar https://github.com/neynarxyz/nodejs-sdk
Or you can also use the utility function signKeyRequest inside this package https://github.com/farcasterxyz/hub-monorepo/blob/main/packages/core/src/signers/viemLocalEip712Signer.ts
****/
@manan19
manan19 / insert_root_parent_cast_and_return_count
Created September 6, 2023 00:02
PostgreSQL function to calculate the threadHash or root_parent_hash for all casts
DECLARE
rows_inserted INTEGER;
BEGIN
WITH RECURSIVE root_mapping AS (
-- Base case: Casts without a parent and with a timestamp in the last hour
SELECT hash, timestamp, hash AS root_parent_hash
FROM casts
WHERE parent_hash IS NULL
@manan19
manan19 / client_diff.md
Created June 21, 2025 18:47
diff to support headers on waypoint grpc

Here's the minimal diff to add custom header support:

+ use std::collections::HashMap;
+ use tonic::{
+     metadata::{MetadataMap, MetadataValue},
+     Request,
+ };

 #[derive(Clone)]
WITH balances AS (
SELECT
"to" as owner,
SUM(
CASE
WHEN "from" = '0x0000000000000000000000000000000000000000' THEN value
WHEN "to" = '0x0000000000000000000000000000000000000000' THEN -value
ELSE value
END
) as balance