How does Farcaster Storage work?
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
This article assumes you know what Farcaster Hubs are.
Storage on Farcaster Hubs
What is Storage on Farcaster? Storage is a means of keeping track of usage on the Farcaster network. Storage is accounted for in bytes to be used for posts, reactions, links, profile data and verifications.
One storage unit is one message of the according type. A payment is required yearly to keep all messages of the fid (user) stored on the network.
The accounting for the storage is done on a blockchain via the Storage Registry. Blockchains provide the financial infrastructure required to facilitate payments for storage as a credibly neutral accounting layer that is not easily tampered with providing immutable history.
For a new message (e.g. post, like, follow and so on) to make it to the Farcaster network the fid must have enough storage allocated in the Storage registry.
Why do we need to pay for Storage on Farcaster?
Why? Because the Farcaster network is a decentralized network, and as such, it’s important to keep the network running smoothly. By limiting the amount of data one can maximally store and placing a cost one can’t infinitely spam it.
One payment for a storage unit lasts one year. So units are freed if not used. The payment can be done for any fid at the Storage Registry so apps could fund it for their users or you may pay for your friends.
Why does there need to be a Storage limit?
Without a limit on storage, the network could be infinitely spammed. Additionally it could grow so quick that it would bring down the computers making up the network.
When are messages pruned (deleted)
If an account exceeds its limit for a message type, the oldest message is pruned to make space for the new one. If the whole storage unit expires there is a grace period of 30 days before the messages are pruned.
The user can keep using the network without paying for more storage and Hubs can keep the storage load under control. An account can always purchase more storage to increase its limits.
Additionally an account can delete messages at any time by publishing a corresponding delete message. The delete message will remove the contents of the original message, leaving a tombstone in its place. A deleted message will still count towards the account’s storage limit until it expires by being pushed out by a newer message.
Though remember that the original message was publicly sent so there is no guarantee that no one has kept track of it even though the network itself deleted it.
How do Hubs know my Storage limits?
Hubs interact with the Storage Registry smart contract on the Optimism blockchain through RPC calls. The Storage Registry maintains a record of how much storage each FID (Farcaster ID) has purchased and when it expires.
When a Hub starts up, it establishes a connection to Optimism through an RPC endpoint and begins monitoring the Storage Registry contract for events. This allows the Hub to track storage allocations and expirations in real-time.
This storage information is cached locally by the Hub and updated whenever new Storage Registry events are detected on-chain. The Hub uses this data to enforce storage limits when processing new messages from users.
Onchain Events related to Storage
The onchain events are also synced across the network as onchain event messages.
Onchain (Storage Registry Smart Contract)
What is the maximum amount of storage?
That can be read from the Storage Registry smart contract using the maxUnits() function. As of writing (2024-12-26) the maximum amount of storage is 1,000,000 units.
How to read Storage values?
To see how much storage a user has, you have to query Hubs. The Hubble API exposes a GetCurrentStorageLimitsByFid
function.
Onchain you would aggregate over all rent events.
How to pay for Storage?
The Storage Registry smart contract exposes methods to rent storage (pay) batchRent
and rent
. You can interact with these methods to rent storage units for a given FID.
How can I extend my Storage?
To extend your personal storage either you use tools like your Farcaster client’s built in Storage feature (for Warpcast that’s in Settings > Storage which allows you to see limits and extend storage).
Though there are other tools like Cast Storage and of course the Smart Contract directly.
Ressources
You can read more about Storage