QuotaCell: Let your team spend without handing over the treasury

Imagine you’re running a project with a small team.

There are expenses to handle, suppliers to pay, and people who need to get things done.

You can’t be available to approve every single payment. But you also don’t want to give everyone unrestricted access to the treasury.

So how do you let people spend independently while keeping control of the funds?

That’s the problem I’ve been working on with QuotaCell.

Here’s how it works

Say your project treasury holds 200 tokens.

You want Alice and Ben to handle payments, but you’ve only approved 100 tokens for them to spend altogether.

Alice has a personal limit of 70 tokens, and Ben has a limit of 50. Each can only pay their approved recipient.

The important thing is that they’re both spending from the same 100-token allowance.

If Alice spends 60, Ben can spend another 40, not 50.

Once that 100 is exhausted, neither of them can make another payment under that allowance, even though the treasury still has funds.

Adding more tokens to the treasury doesn’t reset it. Neither does receiving a payment back. The owner has to explicitly renew the spending authority.

And Alice and Ben can make their permitted payments without needing the owner to approve every transaction.

Why CKB?

What interested me wasn’t just displaying a budget or tracking how much each person had spent.

It was making those restrictions enforceable even when someone isn’t using our application.

With QuotaCell, the shared allowance is part of a native CKB policy protecting the funds.

That means someone can have a valid signing key, construct a transaction using another tool, and still have that transaction rejected if it breaks the spending rules.

The limits don’t depend on QuotaCell’s server agreeing to enforce them.

The owner also retains authority to revoke permissions and recover the protected funds through the policy’s supported recovery rules.

I think that’s an interesting foundation for building applications where people need freedom to act, but not unlimited authority.

There’s more we can build around this

Team spending is where QuotaCell started, but we’ve also been investigating how the same approach could support other applications.

Autonomous agents are one particularly interesting direction.

Imagine two agents handling different operational tasks. One pays an approved data provider, while another pays for a separate service. They have their own keys and restrictions, but share one overall spending allowance.

We’ve already investigated this architecture against existing CKB agent and wallet infrastructure. The current policy can accommodate two software-controlled signers without changing its core spending rules. The next step is connecting those agents through independent transaction builders and testing the complete flow.

There are other possibilities too.

A project could give several contributors controlled spending authority from a sponsored budget. A team could manage delegated operational expenses without issuing unrestricted treasury keys.

We’ve also examined shared access to AI services and other limited resources, including how existing gateways and access-receipt infrastructure could help. That needs a different enforcement approach because spending tokens and consuming an off-chain service aren’t the same thing.

What connects these applications is the idea of sharing limited authority without surrendering control of the entire resource.

What we’ve built

QuotaCell already has a compiled native CKB spending policy that we’ve tested through local CKB verification.

We’ve run 89 verification cases, with all 89 producing their expected results: 33 accepted transactions and 56 rejected transactions.

The cases cover permitted payments, shared allowance exhaustion, attempts to bypass restrictions, invalid policy changes, owner administration, and recovery behavior.

The current implementation supports a specific synthetic xUDT profile with two delegates and fixed recipient rules. It’s not yet deployed to a public network or independently audited.

We’re now moving from that native foundation toward the transaction-building, signing, recovery, and application experience needed to make QuotaCell practical. Supporting the assets and payment workflows teams actually use is an important part of that work.

Where we’re going

I want QuotaCell to become something a project owner can actually use to manage delegated spending, while making the underlying policy useful to other CKB applications too.

We’ve already learned quite a bit from examining existing wallets, agent infrastructure, native CKB scripts, and access-control systems. There’s useful work to build on, and there are also areas where new infrastructure could make a difference.

I’m sharing QuotaCell here because I think the underlying idea has room to grow beyond the original team-spending use case.

If you’re building wallets, working with agents, managing project funds, or experimenting with shared resources on CKB, I’d love to hear the situations where this kind of control could be useful, along with approaches or limitations we should consider.

I’ll keep sharing meaningful progress as QuotaCell develops, and I hope some of the ideas and technical discussions here can help shape what we build next.

5 Likes

Nice one. The shared allowance is the part I’d poke at: if Alice and Ben both spend from the same 100, I’m guessing the remaining allowance sits in one cell that every payment consumes and recreates? If so, two payments built at the same time will race for it and one gets rejected with a dead cell. I hit the same thing in CrowdCell once pledges started updating the campaign’s on-chain total, since every pledge spends the same campaign cell. What I ended up doing is catching that error in the tx builder, waiting for the cell to move and rebuilding on the fresh one, up to 4 tries. Fine at low volume, but worth planning for if agents are firing payments on their own. Did you go with one shared cell or split it somehow?

3 Likes

Yeah, that’s exactly how we’ve structured it for now. One shared Cell that gets consumed and recreated whenever the allowance changes.

We’ve considered the concurrency issue too, although we haven’t tested the full retry flow against a running node yet. Your CrowdCell experience is helpful here. Fetching the latest Cell and rebuilding the transaction is the approach we’re considering, with the allowance checked again against the new state.

For now, I’d rather keep the shared Cell and see how it performs in practice before considering a different structure.
Appreciate you sharing how you handled it.

2 Likes

A small update on QuotaCell since I introduced it here last week.

I’ve now tested the shared spending allowance using signed transactions sent to an isolated CKB node, rather than relying only on the earlier contract tests.

For the test, Alice and Ben had separate keys and spending limits, but shared an overall allowance of 100 tokens.

Alice paid 60 successfully. Ben then tried to pay 50, but CKB rejected the transaction because only 40 remained in their shared allowance. When Ben tried 40 instead, it went through.

The final result was 100 spent between them, with another 100 tokens still protected in the treasury.

What I wanted to confirm was that the limit is enforced by CKB itself, not just by the application building the transactions. The owner didn’t need to approve each payment either.

I’ve also made the implementation, tests and transaction evidence public here:

This is still experimental work using synthetic tokens on a local development chain. There are important things left to handle, particularly payments happening at the same time, CKB capacity costs and making recovery easier for owners.

The earlier tests also cover permission changes and owner recovery, although those actions haven’t yet been demonstrated in the running-node test.

I appreciate the technical questions raised on the first post, especially around handling concurrent payments. They’ve helped clarify what still needs work.

QuotaCell progress: Owner revocation and treasury recovery now tested on CKB

In my previous update, I shared how QuotaCell enforces shared spending limits through CKB scripts.

This week, I focused on another important question: Can a treasury owner revoke delegated access and recover the protected funds without relying on the delegates?

I’ve now tested the owner-control lifecycle using real signed transactions on a fresh isolated CKB node, without modifying the existing policy.

The results:

  • Revocation: An owner-signed transaction revoked a delegate’s authority and committed successfully.

  • Enforcement: A newly signed payment using the updated policy state reached the node and was rejected at Q17 because the delegate was disabled. This was not a stale-Cell rejection.

  • Treasury recovery: The owner closed the policy and recovered all 200 protected synthetic tokens, along with the fund Cell’s 154 CKB capacity, into an owner-controlled token Cell. No delegate signature was required.

  • Recovery after closure: I deposited 50 of those same tokens back into the protected treasury after closure. The policy remained CLOSED, and a separate owner-signed sweep successfully recovered the deposit.

The final owner balance remained 200 tokens, since the late deposit reused previously recovered funds.

An important limitation also became clear in the executed lifecycle.

The current policy retains all 600 CKB of its policy Cell after closure, with an occupied minimum of approximately 572 CKB. That capacity isn’t a transaction fee, but it remains unavailable for reuse under this experimental design.

The recovered fund capacity is also held in owner-controlled typed token Cells, not automatically converted into freely spendable CKB.

This is still an experimental implementation using synthetic xUDT on a local CKB node. It isn’t a public-testnet release, independent reproduction or a security audit.

The broader goal is to make shared spending authority practical for CKB teams and applications, with enforceable delegation, owner control, recovery and reusable integration components.

The new signed transaction evidence, capacity accounting, validation tools and reproduction instructions are now public:

Reproduction instructions:

The next challenges are making owner recovery independently usable, improving the policy’s capital efficiency and supporting practical native CKB payments.

2 Likes

Great progress!

A couple of things I’d consider for the next iteration:

First, concurrency and payment idempotency.

I’d test probably two independent transaction builders spending simultaneously, including cases where a transaction is broadcast but its status is uncertain.

Second, capital efficiency.

The 600 CKB retained by the policy Cell seems a little expensive for smaller budgets. It might be worth exploring whether the policy state can be made more compact, or whether a closed policy can eventually be retired while still allowing recovery of late deposits.

Longer term, I’d also think about how delegates and approved recipients can be rotated without resetting the spending history.

I quite like the direction overall, it is starting to feel like a useful primitive for CKB, beyond just treasury management.

2 Likes

Thanks, these are good points.

On concurrency, the shared policy Cell prevents two transactions from spending the same state, but that doesn’t solve payment idempotency. The harder part is handling an uncertain broadcast without accidentally creating another payment during recovery. That’s something I still need to test with independent builders.

The 600 CKB issue is also more than just the state size. The current CLOSED policy stays around to allow recovery of late deposits, so reducing its size alone wouldn’t solve the capital being retained. I need to find a safer way to handle retirement without losing that recovery path.

And I agree on rotation. Being able to change delegates or approved recipients while preserving the existing spending history would be important for real teams.

These are still open design problems, but they’re useful priorities for the next stage. Appreciate the detailed feedback!

1 Like

QuotaCell update: From test tokens to a working CKB spending Pocket

When I first shared QuotaCell, I was trying to solve a simple problem.

How do you let contributors, teammates or automated agents pay project expenses without giving them the main treasury key or approving every payment yourself?

The first experiments showed that CKB could enforce spending limits directly on-chain. But they were still using synthetic test tokens and a preconfigured setup.

The feedback from @Ayoub_Lesfer and @ArthurZhang raised important questions about payments happening simultaneously, uncertain transaction outcomes, and the 600 CKB that remained locked after closing a Pocket.

I’ve spent the past week working through those problems.

Here’s what’s changed.

1. QuotaCell now works with native CKB.

Two independently controlled accounts can spend from the same protected budget. Each has its own spending limit and approved recipient, while CKB enforces the combined limit.

The owner can remove spending permission without needing the contributor’s approval.

2. Closing a Pocket now returns most of its policy capacity.

Previously, closing left 600 CKB locked. The newer design returns 466 CKB to the owner, retaining 134 CKB so later deposits can still be recovered.

This is a new contract version, not an automatic upgrade of the earlier one.

3. We’ve tested what happens when payments collide or the network response disappears.

Two independent payment processes competed for the same funds, and only one transaction committed in each test. I also tested recovering transaction outcomes after losing the network response.

There are still limitations around retries and recovery across multiple devices, but these are no longer just theoretical scenarios.

4. The biggest milestone: QuotaCell now completes its full spending lifecycle through a browser.

Starting with an empty application, the local test successfully:

  • Created and funded a new Pocket.

  • Allowed two independently controlled accounts to make permitted payments.

  • Removed a contributor’s spending permission.

  • Closed the Pocket and recovered the remaining protected funds.

  • Recovered CKB deposited after closure.

  • Reopened the correct Pocket after restarting the application.

The server held none of the owner or contributors’ private keys.

This is a working local prototype, not a public release yet. The successful browser test used disposable signers on an isolated CKB chain. The interface still exposes developer-level details, and real wallet integration and public testnet testing come next.

All the work and evidence are public:

Next, I’m working on making QuotaCell easier to use, removing the raw developer inputs and preparing for real CKB wallet testing.

But I’m curious about something practical.

If you’re running a CKB project or building automated payment bots, how do you handle expenses that someone else needs to pay?

Are you signing each transaction yourself, or putting funds into a separate wallet that a teammate or bot controls?

Which gives you more trouble: constantly approving payments, or worrying about how much money someone could access if their key were compromised?

That’s the problem I want the next version of QuotaCell to make easier.

3 Likes

Nice, getting the close down to 134 CKB is a big improvement. To your question, for CrowdCell’s keeper we went the separate wallet way but kept it small on purpose. The bot has its own key on the indexer server and the only thing it pays from that wallet is the finalize fee. Release and refund fees come out of the pledge cell itself (the pledge lock lets at most 1 CKB be deducted, the rest has to go to the creator or the backer), so the wallet only needs a few CKB and the bot warns when it drops under 50. If that key leaked the worst case is someone spends the fee money, not the pledges. The annoying part is topping it up by hand, so a capped budget a bot can spend from is the bit I’d actually find useful.

4 Likes

Thanks @Ayoub_Lesfer, this is really useful.

I hadn’t considered that side of it. You’re deliberately keeping the keeper wallet small to limit the damage if its key leaks, but that also means having to keep topping it up manually.
I can see how a capped spending Pocket could help here, especially if it could automatically replenish the keeper wallet without giving the bot unrestricted access to the treasury.
QuotaCell doesn’t handle that automatic refill yet, but this is a concrete workflow I’d like to explore.
One thing I’m curious about is,would automatically topping up the existing keeper wallet when its balance runs low solve the problem, or would you prefer the bot to pay its fees directly from a protected budget?

2 Likes

Thanks @Ticoworld, great project idea, it really tackles a practical use case.

To your question: in CSR, each runner has its own small wallet that the operator funds once. It pays the runner’s transaction fees by itself, and any surplus can be swept automatically to the owner’s address.

CSR (CKB Service Runner) could also be a solution for the keeper refill you discussed with @Ayoub_Lesfer.

CSR lets independent full nodes run scheduled or on-demand jobs on CKB. Combined with QuotaCell, the split could look like this:

  • QuotaCell sets the limit: how much can be spent, by whom, and to which recipient.
  • CSR does the work: for example “when the keeper wallet drops below X, move Y from the Pocket to the keeper”, so nobody has to top it up by hand.

The cap stays enforced by your policy on chain, and the refill no longer depends on a single person or server.

The CSR testnet is fully operational, so you can test an integration there whenever it suits you. I’d be pleased to answer any questions.

2 Likes

Thanks @psawyerberlin , this is a really interesting connection.
I hadn’t considered CSR as the automation side of QuotaCell. Combining its scheduled jobs with QuotaCell’s spending limits could be useful for the keeper-wallet problem Ayoub described.
The part I’d like to understand better is signing. Could a CSR job construct and submit a payment using a restricted QuotaCell delegate key, without needing access to the owner’s key?
If that’s supported, I’d be interested in testing a small refill flow on testnet before going further.

Appreciate you sharing this

Thanks @Ticoworld, and sorry for the slow follow-up. I wanted to check this properly against how CSR actually works before answering.

The honest answer: yes, technically, but it doesn’t add much.

A CSR job can’t carry a key of its own. Every CSR runner signs its transactions with its own service key, and services never see that key. So the only way to use a QuotaCell delegate today would be to register one specific runner’s key as the delegate. The owner’s key would never be needed, but the refill would then depend on that single runner being online.

That’s essentially what Ayoub already has with his keeper bot, just running somewhere else. The value of CSR is that any node can execute a job, and a fixed delegate key removes exactly that. So I have to be honest: with the current delegate design, CSR isn’t really a good fit for the refill.

An idea, if you find it interesting: no delegate key at all

Since the recipient (the keeper) and the amount are fixed, the Pocket could in principle offer a keyless refill rule: “anyone may move exactly Y to the keeper address, at most once every N blocks.”

  • The funds can only ever go to the keeper.
  • The cooldown and the Pocket’s cap limit how much can move.
  • There is no delegate key to protect.
  • The owner keeps full control.

The “keeper below X” check would then run as a small CSR job that any node can pick up, with no single bot or server to keep alive.

I haven’t checked whether something like this fits into Q’s design, or what trade-offs it brings, so please take it only as a suggestion. You know the policy much better than I do.

Either way, thanks for the open discussion, and I’m happy to help test if a direction emerges where CSR makes sense. I’m also on Telegram: View @ckbrunner if you’d like to talk it through.

QuotaCell is growing in popularity!
https://x.com/RyptoCrypto/status/2119444821399994496?a=5cSF2FbEaUzjVFaBE1M&s=20

Thanks @psawyerberlin, that makes sense now. I see why tying QuotaCell to one runner would defeat the purpose of CSR.

The keyless refill idea is interesting, especially with the keeper-wallet problem Ayoub mentioned. I hadn’t considered approaching it that way.

I want to look into how the refill limits and cooldown could work safely before making changes to QuotaCell.

For now, I’m working on getting the existing Pocket running with real wallets on Pudge. Once I’ve explored this further, I’ll reach out on Telegram so we can talk through a possible test.

And thanks for sharing the video too, Really appreciate the feedback and support

3 Likes

是否可以尝试让 QuotaCell 先成为某些 DAO / 小型组织的一个简单易用的工具?比如对于某个社区的国库资金的管理。

1 Like

Thanks @RetricSu, yes, absolutely. That’s actually one of the practical uses I had in mind when I started QuotaCell.

For a small DAO or community group, the idea would be to set aside a working budget for everyday expenses, then allow selected members to make payments within their own limits and to approved recipients. Everyone draws from the same shared budget, with CKB enforcing the restrictions.

The owner can revoke spending permissions and recover the remaining funds whenever needed.

I think the important part is making this simple enough that a community organizer can set it up and manage it without needing to understand the underlying CKB scripts.

That’s what I’m working toward. The spending and recovery flows are already working locally, and I’m currently testing real-wallet support on Pudge. The interface still needs work before I’d call it easy to use.

So yes, I think starting with small DAOs and community organizations makes sense. I’d be interested to hear which parts of managing community funds you think are most troublesome today.

1 Like

我并不是一个深入到社区治理与DAO相关的人,所以不太能知晓其中的痛点。但我会非常乐意看到 CKB 上有相关的实践。毕竟社区是这个网络里最重要的资产,给社区提供工具看起来是理所当然的事情。我同意你所说的,关键在于将这一切做得足够简单,哪怕非技术人员也能很容易使用起来这个工具。

1 Like

a little suggestion before the public demo, the current discovery path appears to reject multiple protected fund Cells or unsupported matching Cells, so it would be worth checking that an extra deposit cannot prevent the Pocket from opening or the owner from recovering supported funds.

1 Like

Topping up the existing wallet, I think. The keeper only pays the finalize fee from its own wallet, and it already checks its balance every cycle and logs a warning below a threshold (off-chain/indexer/src/bot.ts), so a refill when it drops below X fits in without changing how it signs. Paying fees straight from a protected budget would put the Pocket cell in every finalize tx, and once there’s a second keeper they’d both be fighting over that one cell. @psawyerberlin’s split, QuotaCell for the cap and a CSR job for the trigger, sounds like the right shape to me, and it’d be a nice thing to try on testnet once the keeper is split out of the indexer.

3 Likes