Skip to content

Docs/revamp payments cookbook#677

Open
nijoe1 wants to merge 7 commits intomasterfrom
docs/revamp-payments-cookbook
Open

Docs/revamp payments cookbook#677
nijoe1 wants to merge 7 commits intomasterfrom
docs/revamp-payments-cookbook

Conversation

@nijoe1
Copy link
Copy Markdown
Contributor

@nijoe1 nijoe1 commented Mar 17, 2026

  • Replaced the filecoin-pay cookbook with a comprehensive Payments & Storage cookbook covering the account model, payment rails, rate mechanics, and deposit calculations. Incorporates content from the HackMD writeup. Closes Update Filecoin Pay cookbook #651
  • Split the Storage Context developer guide — moved split operations (store, pull, presign, commit) into a dedicated Split Operations guide, keeping Storage Context focused on context creation and provider selection
  • Updated Storage Costs guide to showcase the new costs API
  • Added FOC Storage MCP to community projects

@nijoe1 nijoe1 requested review from hugomrdias and rvagg as code owners March 17, 2026 13:44
@github-project-automation github-project-automation bot moved this to 📌 Triage in FOC Mar 17, 2026
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 17, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
synapse-dev fece11f Commit Preview URL

Branch Preview URL
Mar 31 2026, 04:16 PM

@rjan90 rjan90 moved this from 📌 Triage to 🔎 Awaiting review in FOC Mar 17, 2026
@rjan90 rjan90 added this to the M4.1: mainnet ready milestone Mar 17, 2026
@BigLep
Copy link
Copy Markdown
Contributor

BigLep commented Mar 19, 2026

@rvagg or @hugomrdias : can you please review so we get this in for M4.1?

@BigLep BigLep requested a review from juliangruber March 19, 2026 06:59
:::tip[SDK Usage]
This cookbook explains the underlying mechanics. For practical usage:

- **Code examples**: [Storage Costs](/developer-guides/storage/storage-costs/)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be using / anchored links in these docs? wouldn't it be safer to use relative links? I don't really know Astro but this seems brittle to me

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this https://github.com/HiDeoo/starlight-links extension helps a lot with links and we have https://github.com/HiDeoo/starlight-links-validator in the build

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job pulling it together, the old doc was one big hand-wave so important to improve on it. But this new doc needs a framing adjustment: it reads like Shashank's design doc for getCosts() turned into a user-facing doc. That doc was internal detail for building an API that helps us hide all this complexity from the user, but then presenting it here reintroduces it. "Account state", "rate precision", "the buffer problem", these in particular are far far too in-depth for user-facing docs, even docs we expect AI to read.

What an SDK developer needs from a "Payments & Storage" cookbook:

  • How much does storage cost (pricing table, floor, CDN)
  • What happens when I call prepare() / getUploadCosts() (already in storage-costs.mdx)
  • What happens if I run out of funds (high-level: 30-day grace, then data at risk)
  • Most importantly, the mental model that they need to function with this system: you deposit, FWSS streams payments to SPs, done

I think there is scope to go into some detail about Filecoin Pay's dynamics, but strictly if it's framed as "advanced", and a lot of what's in here goes beyond that. Account struct fields are not relevant. actualLockup is too much detail when FWSS is a 30-day fixed lockup, conceptually it's much simpler. Solidity source for _calculateStorageRate is way too deep, solidity modifier behaviour like settleAccountLockupBeforeAndAfter, the whole buffer problem and the pseudocode, all the edge case details about terminations and even most of the debt stuff is too deep. These kinds of things are useful for us to understand and to frame how we build an interaction layer with the system for the user, but if we're needing to give them to the user then we may as well not have an SDK.

The old cookbook was one big hand-wave, so we need to find the middle ground. I think we could trim it to about 1/3rd of this this length: keep pricing model (rates, floor, CDN costs), the three-rail-per-dataset mental model, "what underfunded means for you" (keep it brief), operator approval (brief, for storage we just have the one to approve but knowing what that means is relatively important), and point to storage-costs.mdx for the code. Cut everything about internal formulas, Solidity source, buffer pseudocode, and settlement mechanics.

Even though you've got solid context here and good accuracy, when you're working on this further, I'd suggest you load the filecoin-pay README.md and SPEC.md into your agent's context to get full accuracy, just don't be lured by your AI to go into deep detail, it's for accuracy and this needs to be external developer facing.

Also, you need to account for #666; the data set creation fee is back, so it's now 0.16 USDFC (no CDN) and 1.16 USDFC (with CDN), not 0.06/1.06.

The guiding principle: the less a developer has to know about internals, the better. Storage should be something you bolt onto an app, not something that requires understanding contract settlement to use.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @nijoe1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things have gone awry in here I think.

I rewrote this doc as part of the multi-copy upload flow and intentionally tried to downplay use of StorageContext directly except inasmuch as it gives you the ability to do the split operations to take control of the upload operation because you have opinions or needs that upload() doesn't cover. In a sense, StorageContext becomes just a minimally stateful mechanism to do store() / pull() and commit() across multiple providers and coordinate the dance yourself. Aside from that there's not a great reason to use it directly. I even debated removing StorageContext#upload() entirely. But you've restored a lot of the stuff that I intentionally removed, in revamped form. I would like StorageContext to become more of an implementation detail that you need to know about for split operations and deeper control than something that needs a dedicated page.

The whole section on "Using synapse-core Directly" has been removed, was this a mistake? The original framing of the docs for storage were: (1) golden path with synapse.storage.upload(), (2) split operations with manual StorageContext creation and coordinating the store() / pull() and commit() dance yourself and then (3) using synapse-core directly to do the same thing, which removes state and adds some complexity due to provider selectio nconcerns, but is not too much more complex than plain split operations.

I don't mind if you delete or rename this file, but I wouldn't mind keeping the layered framing while also gently downplaying StorageContext as a special concern. There is a future where we just make StorageContext go away because as we've trimmed it down we've reduced the difference between using it and using synapse-core directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason I split StorageContext out was practical. The original page was too long and the flow was hard to follow, it opened with split ops + diagram, then detoured into context creation and matching logic before getting to the split examples.

Also StorageContext is not just an upload concept, it's used as input across uploads, storage costs, dataset management and other SDK apis. So I felt it can have its own page.

I even debated removing StorageContext#upload() entirely.

Agreed, can remove and point to split operations.

The whole section on "Using synapse-core Directly" has been removed, was this a mistake?

Intentional. My plan was to move it to the synapse-core page, but I can bring it back into split-operations to keep the layered framing (golden path → split ops → synapse-core direct). What's your preference?

There is a future where we just make StorageContext go away

I get that and I can see the SDK moving internally from context to core, but I feel like we are not there yet. This is something we can improve incrementally as the SDK evolves. Let me know how you'd like to proceed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

## Upload Preparation

---
Before uploading, the **WarmStorage operator** must be approved and your account must be funded. FWSS requires a 30-day prepayment buffer — when your balance drops below 30 days, the provider may remove your data.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already in here but it's misleading and we should take the change to tweak it, it's more like "FWSS uses a 30-day lockup (prepayment) period. If your account becomes underfunded, the provider may terminate the storage agreement, after which you have 30 days before data removal."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty good changes here 👌

nijoe1 and others added 2 commits March 20, 2026 11:41
@rjan90
Copy link
Copy Markdown
Collaborator

rjan90 commented Mar 30, 2026

@nijoe1 Apart from getting this branch up to date with the base branch - is this PR ready for a re-review?

@nijoe1
Copy link
Copy Markdown
Contributor Author

nijoe1 commented Mar 30, 2026

@rjan90 I am waiting for one answer from Rod. Then I can work on the refinements. Most of the other comments I have resolved them just haven't pushed as they might require some small changes based on Rod's resp!

@hugomrdias
Copy link
Copy Markdown
Member

@nijoe1 ping me in slack if you need to chat about this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🔎 Awaiting review

Development

Successfully merging this pull request may close these issues.

Update Filecoin Pay cookbook

6 participants