0

If you have built a custom Substrate-based chain and added Substrate pallets to enable on-chain governance (i.e. pallet_democracy, pallet_referenda).

How would you split the costs between participants of an on-chain governance proposal if it passes?

Since transaction fees are payed at the moment that you create or vote on a proposal I think only way to split the costs would be to calculate it after the proposal passes, and then have the treasury send refunds directly to the creator and voter accounts of that proposal or give them credit that they may claim.

So I think there would need to be function in the on_initialize or on_finalize method of a custom pallet that detects when a proposal passes, calculate the overall amount spent on transaction fees by the creator and voter accounts, and then split that overall amount evenly across the list of accounts, and send the refund or setup a way for them to claim it.

1 Answer 1

2

pallet_collective allows to execute certain calls based on membership: https://github.com/paritytech/substrate/blob/21d58f6f7b3ed2ea529f3c118b2e042b29551672/frame/collective/src/lib.rs#L450 You can use this for inspiration.

On the note of splitting a fee, some time ago, I also implemented a custom voting pallet and split the fees between losing and winning sides. Maybe this will help you too: https://github.com/SkymanOne/vote-pray-love/blob/d44e042306a323ad64c9d9ebc5f42d3d84acdd17/pallets/slashing-voting/src/lib.rs#L257

TLDR: you basically keep internal count of how much fee each member is rewarded and then transfer the corresponding amount from the pot to that member.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.