Collaborative decision deposits: live on Kusama, open for review

A Kusama Wish for Change needs a 666.67 KSM decision deposit before it can go to a vote. Governance takes that deposit from one account. A proposal can have support and still time out because nobody can carry the whole amount.

We have built a contract that lets people and groups share it. The first pool is live for our Wish for Change #676. We are asking for code review and people to try the Paseo rehearsal.

This is experimental and has not had an independent review. We deployed before that review to leave time before #676 times out. A killed referendum loses the deposit, and a contract bug could also put contributions at risk.

How it works

Each pool is fixed to one referendum and its exact deposit. It has no owner, admin key or upgrade path.

People contribute from their own accounts. The payment that fills the pool tries to place the deposit in the same transaction. If placement fails, the contribution stays in the pool and anyone can retry. Contributors can withdraw while the pool remains open, before placement.

After the referendum ends, anyone can reclaim the deposit and send payouts to the contributing accounts. These are separate contract calls. No watcher is running yet, so repayment needs someone to act through the page. A contributor that refuses payment does not block the others. If funding falls short, contributors can withdraw, or anyone can close the pool after its deadline and start payouts.

Approved, rejected, cancelled and timed-out referenda allow a refund. Killed referenda do not. Network fees are additional.

Try it together on Paseo

Paseo #147 mirrors #676’s proposal byte for byte, with the same origin and enactment. Its pool needs 20,000 PAS, with a minimum payment of 500 PAS. Funding closes 2 November 2026 at 12:00 UTC.

Connect an Ethereum account in Talisman or MetaMask. If it needs test PAS, the page opens the faucet with the account filled in. Leave enough for transaction fees.

Paseo’s Wish for Change decision period is 28 days, compared with Kusama’s 14. This rehearsal cannot return funds within hours. A separate 1 PAS proof pool on Paseo #145 is expected to end around 6 November. The public-network refund is still unproved.

Earlier work and what needs review

This follows Moonbeam’s 2023 discussion, the 2024 decision deposit track proposal, and RFC 151 on crowdsourced deposits. This experiment uses Asset Hub’s EVM and XCM precompile without a governance upgrade.

Placement has worked on public Paseo. The Kusama fork suite passed 88 checks, including refunds, failed placement and a recipient refusing payment. Fork balances and some governance outcomes were injected, so those tests do not replace public-network evidence or independent review.

We would particularly welcome review of the XCM encoding, the balance checks around placement and reclaim, and the payout handling. Please open an issue in the repo or reply here.

The Kusama pool needs 666.66666666 KSM, with a 5 KSM minimum except for the final top-up. Funding closes 3 November 2026 at 12:00 UTC, ahead of #676’s estimated timeout that evening. Please try Paseo and read the code before deciding whether to contribute KSM.

Birdbrain is a Decent initiative that tests, learns and educates in public.

Progress on the #676 pool.

It holds 380 of 666.67 KSM from three addresses, so 286.67 KSM is still needed before funding closes on 3 November at 12:00 UTC.

You can test the contract before trusting it with much. Until the deposit is placed, any contributor can call withdraw() and take their KSM straight back, then pay in again. The minimum is 5 KSM, and the payment that fills the pool places the deposit, so the window closes then.

Since launch, the page at birdbrain.wtf/tools/cdd has gained:

  • a list of every payment in and out, each linked to its transaction
  • the Polkadot-format address of a connected Ethereum account, so Nova and polkadot.js can send to it
  • names from the Kusama People chain, where a contributor’s account has one
  • an Ask box for wallet problems, such as Talisman’s network error or paying from a multisig

@Zealynx, thank you for the review. The duplicate contributor entry is real and harmless, as you said, and the page now shows each address once. The weighMessage() revert in reclaim() and the stranded plain transfer are both noted for the next version. The live contract has no admin, so it can’t be patched. Until then, please pay in through the page or contribute(). KSM sent straight to the contract’s account will not be repaid.

Thanks @birdbrain for this experiment. Looking forward to the outcome and any other code review you receive. This could be excellent to replicate for future referenda on Kusama or even Polkadot.

I hope you are able to crowdfund the entire decision deposit before the ref times out. For the sake of experimentation I just contributed 25 KSM to your pool.

I first tested adding 5 KSM, then withdrawing it and it works.

A short update on the #676 pool. It now holds 435 of 666.67 KSM, so 231.67 KSM is still needed before funding closes on 3 November at 12:00 UTC. Thanks @florentina57 for the 25 KSM, and for testing a withdrawal first.

Two fixes to the page at birdbrain.wtf/tools/cdd. The contract is unchanged.

  • Choosing a wallet. Someone with more than one wallet installed told us the page gave them no choice. It used whichever wallet held window.ethereum, so you could connect the wrong account. The page now lists the wallets that announce themselves (EIP-6963), and the payment goes through the one you pick.
  • Paying everyone back. Testing that fix found a worse bug of ours. The “Pay everyone back” button counted each address once, but an address that withdraws and pays in again is listed twice by the contract. So the button stopped short of the last contributors. This pool has 8 entries for 5 addresses, so one contributor would have been missed. No payout has run yet, because the pool is still open, and the contract was never the problem: anyone can call payout with the full range, and each contributor can call claim(). The button now covers the whole list.

Tests: the page in Chromium against a fork of Kusama Asset Hub, 33 checks passed, up from 19. They cover two wallets, one wallet, a refused request, a popup left unanswered, a wallet with a hostile name, and repayment with a repeated address. The wallets in these tests are simulated, so tell us if a real one misbehaves. Test log and source.

The contract has still had no professional audit.

Just added 10 KSM to support this! Great initiative for Kusama ^^

Where the #676 pool stands. It holds 617 of 666.67 KSM, so 49.67 KSM is still needed by 12:00 UTC today, 3 November. The minimum is 5 KSM, except for the final top-up, and the page is at birdbrain.wtf/tools/cdd.

The referendum itself has longer. #676 times out at relay block 35,945,916, which is about 21:35 UTC at the current block rate. The pool can’t use that extra time. Its funding close was written into the contract as a fixed time when we deployed on 30 October, and the contract has no owner, so nobody can change it. We set the close about six hours before our estimate of the timeout, which was then about 18:45 UTC. That estimate has moved later because relay blocks have run at about 6.17 seconds rather than 6.

After 12:00 UTC the contract refuses new payments and refuses to place the deposit. If the pool isn’t full by then, the contract repays everyone, and we will run that if nobody else does. Until #676 times out, anyone can still place the full deposit directly.

If the deposit is placed, nobody can withdraw until #676 ends, and a killed referendum loses the deposit. The contract has still had no professional audit.

The #676 pool didn’t reach its goal. Funding closed at 12:00 UTC today with 626.5 of 666.67 KSM from 8 addresses, 40.17 KSM short, so the contract did not place the deposit. Thank you to everyone who paid in - it’s a useful first test as the refunds can be run as a group.

We will be setting up a new pool ahead of the deadline of the referendum which times out at about 21:35 UTC so we have time for another go at it.

How refunds work. You don’t need to do anything. Two calls return the money: abandon() closes a short pool after its deadline, then payout() sends each contributor their exact amount, to the address they paid from. Anyone can send them, and they can’t send KSM anywhere else. Birdbrain’s job sends both at 13:00 UTC today and retries if needed. If you’d rather not wait, the page can do it now. We rehearsed both calls on a fork of the live chain just now: all 8 addresses were repaid and the pool ended empty.

What comes next. We will deploy a new pool for #676 from the same code. Its address, deployment transaction and funding close will go in this thread before anyone is asked to pay. #676 itself times out at about 21:35 UTC, and until then anyone can still place the full deposit directly.

Checking nothing has changed. You don’t have to take our word for it. A deployment transaction is the contract’s creation code followed by 512 hex characters of settings. Run this with any pool’s deployment transaction (this one is the first pool):

TX=0xde72f53fb3959e0bff437c1a857f00db3e6cb39391e25bc7c317722754e777e5
curl -s https://eth-rpc-kusama.polkadot.io -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"eth_getTransactionByHash","params":["'$TX'"]}' \
  | jq -j .result.input > pool.hex
wc -c < pool.hex
head -c 13258 pool.hex | shasum -a 256
tail -c 512 pool.hex | fold -w 64

The new pool should print the same size, 13770, and the same hash, 81460ed0411ca2fd6475c5316b0a409f3c661f34af154388773c3a8beeb66e7a. The compiler embeds a hash of the source in that code, so even a changed comment changes the result. The last eight lines are the settings, in hex: referendum, deposit, minimum payment, funding close, Referenda pallet, place call, refund call and weiPerPlanck.

Only the ones we name in this thread should differ. Then check on Blockscout that the transaction created the address you’re paying. To check the code against the source, clone the repo, run bun install && bun compile.ts, and hash .bytecode from build/DecisionDepositPool.json the same way. We ran that from a clean clone and got the same hash.

The same code means the same limits. The new pool keeps the reclaim() issue @Zealynx raised, and a plain transfer to the contract’s account still can’t be recovered. A killed referendum still loses the deposit, and the contract has still had no professional audit.

If we ever change the code, the hash will change, and we will say so here first.

Pool 1 has refunded everyone. All 626.5 KSM is back with the 8 addresses that paid it in, and the contract is empty. The pool was closed at 12:44 UTC (abandon()) and everyone was paid at 12:45 (payout()). This is the first time the refund has run on a public network.

We triggered it. Both calls came from 0xF2d89646065F8AB1b9c99A14209996D4C2Ef5903, ahead of the 13:00 job we described above. That is Decent’s test account, which also paid 5 KSM into the pool. It carries no on-chain identity, so nothing on the chain ties it to us, so we are saying it here. The contract has no approval step and the account had no special power: anyone could have sent those calls, and they can only pay contributors what they paid in.

Pool 2 for #676 is open. Nothing carries over from Pool 1, so taking part means paying in again.

  • Address: 0xfcd8058e46b8ac6f02f1cc71e2912c5ffdc095ce (verified on Blockscout)
  • Deployment transaction: 0x4fcc4644ad6f68ba197dc4cd721acfa75efbdda1cce319c99696bf1a6d601495
  • Funding closes: 20:30 UTC today. #676 times out at relay block 35,945,916, about 21:30 UTC
  • Page: birdbrain.wtf/tools/cdd, which now lists both pools under #676

The same code. Put that transaction in the check from our last post. We ran it and got size 13770 and hash 81460ed0411ca2fd6475c5316b0a409f3c661f34af154388773c3a8beeb66e7a, both matching Pool 1. Of the eight settings only the funding close differs, 6ae9ccc0 in Pool 1 and 6aea4448 here. The limits we listed there still apply, and there is still no professional audit.

If Pool 2 is short at 20:30 UTC it refunds the same way. Anyone can close it from the page, and Birdbrain’s job does it at 21:30 UTC if nobody has.

Birdbrain has paid 200 KSM into Pool 2. The payment came from Birdbrain’s admin account, DJe2JJvcMNjxjkhi3UsoNZwSaYnHQqQB7AAavEAz1wDrJGh. It is the same 200 KSM that Pool 1 refunded at 12:45 UTC.

The pool now holds 200 of 666.67 KSM, so 466.67 KSM is still needed by 20:30 UTC today. #676 times out about an hour later.

If you paid into Pool 1, your refund is back in the address you paid from, and you can pay in again at birdbrain.wtf/tools/cdd. The minimum is 5 KSM, except for the final top-up. Until the deposit is placed, any contributor can call withdraw() and take their KSM straight back. The payment that fills the pool places the deposit, so the window closes then.

If the pool is short at 20:30 UTC it refunds as Pool 1 did, Birdbrain’s 200 KSM included.

Congratulations @birdbrain on your initiative with this experiment, happy to see it in action. I see Pool 2 placed the decision deposit on your WFC ref and the decision period has now started.

Looking forward to seeing the end to end of the process and how eventually this can be used for other Kusama OpenGov refs, or on other networks or for other use cases.

Pool 2 filled and the decision deposit is on #676. Referendum 676 is now deciding.

The last payment, 117.67 KSM from Zugian Duck, came in at 15:58 UTC and took the pool to 666.67 KSM.

The deposit was placed in that same transaction (block 23,359,940), and the decision period began in that block. This is the first time the contract has placed a real deposit on Kusama. Nobody had to call anything by hand.

Nine addresses paid in. By the names on the People chain:

  • 392.5 KSM came from Birdbrain, Decent and accounts close to them: Birdbrain 200, mrb 140, Decent Partners 45, and Decent’s test account 0xF2d8…5903 7.5.
  • 274.17 KSM came from five others: Zugian Duck 117.67, Florentina 75, 0x3a3a…1788 39.5, 0xd777…367a 32 and xcRom1 / x1 10.

Thank you to all of them, and especially to those who paid into Pool 1, got refunded and paid in again today.

You can check this yourself. Query referenda.referendumInfoFor(676) on Kusama Asset Hub. The decision deposit is 666.66666666 KSM, held by JHqkqPcTZuAwEWeunv9Mz1eyfuUSHqr8o5CaFkRgPAu6VrB. That is the contract’s own account: its address 0xfcd8…95ce followed by twelve ee bytes, encoded for Kusama. There is no owner or admin key, and the code check in post 8 still applies.

What changes now:

  • withdraw() is closed. The money stays on the referendum until it ends.
  • The decision period is 14 days, to about 17 November. The referendum can end sooner if it passes confirmation early, or a little later if it is still confirming then.
  • When it ends, anyone can call reclaim() and then payout(), and each address is paid back what it put in. If nobody has done that, a job on Birdbrain’s machine checks every hour and will. Its code is public.
  • If governance kills the referendum, the deposit is lost, for all nine addresses.
  • The reclaim() issue @Zealynx raised still applies, and the contract has still had no professional audit.

The deposit brings #676 to a vote. It says nothing about how anyone should vote, and contributing to the pool didn’t commit anyone to a side.

The pool’s state and every payment are at birdbrain.wtf/tools/cdd.

@Zealynx thanks - we ran it to check. No upgrade is scheduled before #676 ends, and the pool gets through the latest published runtime. If a later upgrade broke the refund call, reclaim() would revert and the KSM would be stuck.

What we ran anyway. The latest published release is v2.5.2 (spec 2005002). We forked Asset Hub at block 23,369,146 with Pool 2 live, applied it with authorize_upgrade and apply_authorized_upgrade, then ended #676 with a Root cancel. The refund message and its weight (78,099,000 refTime, 4,401 proofSize) came out the same on both sides of the upgrade.

  • reclaim() claims the deposit, then payout(): all nine addresses repaid to the planck, pool balance 0. Log
  • Someone else calls refund_decision_deposit first, then reclaim() and payout(): the same result. Log
  • The refund call deliberately broken: on the fork we changed the call index in the pool’s code from 2 to 99, with the full deposit already back in the pool. weighMessage failed and reclaim() reverted. Log

The third run shows this test can fail. It also confirms what you said in your first review: weighMessage runs before the balance check, so the check never gets a say. The comment above that line in the contract is wrong for this case.

If a new runtime is put forward. We will run it through the same test before #676 ends and post the result here. The bytes to protect are 0x0504060100185c02a4020000: an XCM v5 Transact carrying referenda.refund_decision_deposit(676), pallet 92, call 2. If you are working on an Asset Hub release that would change those, or stop XCM v5 decoding, please say so here.

The next version of the contract will weigh the message inside the low-level call, or use a fixed weight.

The test script is public if you want to run it yourself.

Version 2 of collaborative decision deposits (CDD) is written and tested (the code is here) and it is on Paseo now.

The currently active Pool 2 for #676 is still on version 1.

A new page. birdbrain.wtf/tools/cdd now opens on the referenda that need a deposit. Pick Kusama or Polkadot, or Paseo to try it with free test PAS. It lists every ongoing referendum with no decision deposit, and from any of them you can open a pool: the page reads the track, deposit and timeout from the chain, and you choose only the smallest payment and where stray funds go. Pools are read from the factory, and one is listed only if its deposit matches what its referendum needs. A version 2 factory is now deployed on Kusama Asset Hub (verified source), and the page marks its pools as a preview until the code has been reviewed. No pool has been opened through it yet. Polkadot shows no pools until a factory is deployed there.

What changes. @florentina57 asked for the pool to work on other referenda. Version 2 adds a factory contract, so anyone can open a pool for any Kusama referendum on any track, Root included. The same code runs on Paseo with Polkadot’s settings, and it passed the same 41 checks on a fork of Polkadot Asset Hub, including a Root pool of 100,000 DOT (log). A Polkadot factory is a deployment away, but we have not deployed one yet.

The factory fixes the chain settings (Referenda pallet, call indices, the planck-to-wei ratio), so whoever opens a pool chooses only the referendum, the deposit, the smallest payment, the funding close and one address for stray KSM. As in version 1 it holds no money and has no owner.

  • @Zealynx’s fix. reclaim() now weighs and sends the refund message inside a try, so a failure there no longer reverts. As suggested, payouts still cannot open unless the pool’s balance has risen by the full deposit since placing. The fork test sets up the case from the review in both versions: version 1 stays stuck, version 2 settles. A runtime that renumbers refund_decision_deposit or drops XCM v5 still breaks the call itself, so the upgrade test still runs on each Asset Hub release while a pool holds a deposit.
  • KSM sent by plain transfer can come back. A new sweep() sends only what nobody is owed (balance - total) to the address fixed when the pool opened, and only once payouts are open. It never touches a share still owed, including one owed to an address that refuses payment.
  • The funding close comes from the chain. Our tool reads the referendum’s own timeout and closes an hour after it, because the timeout can only be estimated and closing early is what cost Pool 1 for #676 its last 40 KSM. Our page stops taking payments as soon as the referendum stops being ongoing. A payment sent after that, from your own script, can’t place the deposit, and you can withdraw it at once or be repaid after the close.
  • Someone who withdraws and pays in again is listed once, not twice.

A contract cannot read governance storage, so the factory cannot check that a deposit is right. A pool opened with the wrong one fills, fails to place, and repays everyone after the close. The page checks every pool against the live referendum before it lists it. An open SDK pull request, #10107, adds a referenda precompile that would let the pool read the deposit and the referendum’s status itself. If it reaches a Kusama Asset Hub release we will use it, and we are happy to test it against the pool before then.

Tested. 41 checks on a fork of today’s Kusama Asset Hub, including a Root pool of 3,333.33 KSM filled by three payers and repaid to the planck. Log. Then on Paseo with real wallets and real governance: the factory opened a pool for #156, a short pool for #157, and a pool for #157 with the wrong deposit, which filled and did not place. Log. The refunds come when those referenda end: the two short pools after 9 Nov 13:05 UTC, #156 about 13 Nov. We will post both here.

Something Paseo showed that the fork didn’t. The payment that filled the #156 pool was sent with the gas its wallet estimated while the pool was still half full, because another payment landed first. That was enough to pay in, not to place, so the placement inside it ran out of gas. The contract did what it should: the payment stood, the pool stayed open, and a place() from anyone placed it. This can happen on Kusama too, and it applies to version 1. The page now sends payments with gas enough to place, and offers place() whenever a pool is full and open. If you pay from your own script, set the gas yourself rather than trusting an estimate.

Checking a version 2 pool. Pools are created by the factory, so check the factory once, then check that it lists the pool:

TX=0x3cdd9482b36845a8159224b51ba4bc463d1f3fab7d39ec46f3e5361d09fcd2da
curl -s https://eth-rpc-testnet.polkadot.io -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"eth_getTransactionByHash","params":["'$TX'"]}' \
  | jq -j .result.input > factory.hex
head -c 18574 factory.hex | shasum -a 256
tail -c 256 factory.hex | fold -w 64

That should print 463c0fd5ee5127a1ae271fdb8c39d4f7981ef3f52c7ae7d30fe0a7ae39d2376a, then four settings: Referenda pallet, place call, refund call and weiPerPlanck. The pool’s code is inside that hash, so a pool the factory lists under poolsFor(referendum) runs it. Its deposit, fundingDeadline and sweepTo are public on the pool. To build it yourself, clone the repo and run bun install && bun compile-v2.ts, then hash .bytecode from file build/v2/DecisionDepositPoolFactory.json. Version 1’s hash, 81460ed0…6e7a, still reproduces.

What it still can’t do. A killed referendum still loses the deposit, and someone still has to send reclaim() and payout() (Birdbrain does if nobody else does). Neither contract has had a professional audit. We would encourage independent reviews of version 2 and further suggestions to how the initiative can develop.

#676 has ended and Pool 2 has paid everyone back. Referendum 676 was rejected at about 02:56 UTC today. A rejected referendum returns its decision deposit, so the 666.67 KSM came back to the pool.

Nobody called the contract by 03:03 UTC, so Birdbrain’s hourly job did, as promised in post 12:

  • reclaim() took the deposit back from governance.
  • payout() then paid all nine addresses, in block 23,954,149.

Each address got back exactly what it paid in, to the address it paid from: 200, 140, 117.67, 75, 45, 39.5, 32, 10 and 7.5 KSM, 666.66666666 KSM in all. The pool’s balance is now 0. The two calls cost about 0.0001 KSM in fees, paid by Birdbrain.

This is the first time the contract has placed a real deposit on Kusama and then returned it. Pool 1’s refund on 3 November covered a pool that never filled. This one covered the whole path: fill, place, decide, reclaim, pay out.

What hasn’t changed: the contract has still had no professional audit, and the reclaim() issue @Zealynx raised still applies to any version 1 pool. Version 2 fixes it: reclaim() now weighs the message inside a try.

Every payment and both calls are listed at birdbrain.wtf/tools/cdd.

Thank you to the nine of you who put KSM behind getting #676 to a vote.