In the Farcaster protocol, a storage unit is a measure used to allocate and track the amount of data that a user (identified by their Farcaster ID or fid) can store within the network. This system is critical for managing the storage resources of the Farcaster network effectively and ensuring that the network remains scalable and efficient.The specific allocation of storage per unit varies depending on the type of data being stored.Here’s the list of storage allocations per unit:
5000 cast messages
2500 reaction messages
2500 link messages
50 user_data messages
25 verifications messages
5 username_proof messages
The Storage Registry contract controls and tracks the allocation. This contract records the storage allocated to each fid, denominated in integer units.If a user exceeds their storage allocation, Farcaster Hub prunes their old messages. Users can buy more storage units by sending a transaction to the Storage Registry contract or using an app like caststorage.com.This guide demonstrates how to use the Neynar SDK to retrieve a Farcaster user’s storage usage and allocation.Check out this Getting Started guide to learn how to set up your environment and get an API key.First, initialize the client:
Copy
Ask AI
// npm i @neynar/nodejs-sdkimport { NeynarAPIClient, Configuration } from "@neynar/nodejs-sdk";// make sure to set your NEYNAR_API_KEY .env// don't have an API key yet? get one at neynar.comconst config = new Configuration({ apiKey: process.env.NEYNAR_API_KEY,});const client = new NeynarAPIClient(config);