Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 source realm

v0 - Unaudited: This is an initial version that has not yet been formally audited. A fully audited version will be pu...

Readme View source

v0 - Unaudited This is an initial version of this realm that has not yet been formally audited. A fully audited version will be published as a subsequent release. Use in production at your own risk.

commondao (realm)

Reference realm implementation of the gno.land/p/nt/commondao/v0 package for managing Decentralized Autonomous Organizations per the Common DAO Spec (docs/CONSTITUTION.md, Appendix).

What it hosts:

  • DAOs and sub-DAO trees with a Charter (purpose + description), a council, and per-DAO treasury addresses derived as realm sub-identities (cur.Sub("dao/<id>")).
  • Proposals through a per-DAO registry of proposal kinds. Ten default kinds are seeded at creation (text, council updates, sub-DAO creation, dissolution, treasury spend/clawback/freeze, manage-kinds, amend-bylaws); the arbitrary-execution kind is opt-in by governance. The kind set itself is governable (manage-kinds), and manage-kinds can never be deregistered.
  • Treasuries: spends from a DAO's own sub-identity; ancestor clawback and freeze; dissolution sweeps. Freeze blocks every self-initiated movement, including arbitrary execution.
  • Bylaws & Mandates as named plaintext documents amended by verifiable diff patches (gno.land/p/nt/bylaws/v0); the mandates/ folder is reserved for the (deferred) ancestor amendment power.
  • Render pages for DAOs, settings, bylaws, proposals and votes.

Design records live in gno.land/adr/pr6012_commondao_*.md; the extension guide for building your own realm on the /p/ package is in gno.land/p/nt/commondao/v0's README.

Overview

v0 - Unaudited: This is an initial version that has not yet been formally audited. A fully audited version will be published as a subsequent release. Use in production at your own risk.

Package commondao provides a reference realm implementation of the gno.land/p/nt/commondao/v0 package for managing Decentralized Autonomous Organizations per the Common DAO Spec: DAO and sub-DAO trees with councils and charters, a governable registry of proposal kinds (ten defaults plus an opt-in arbitrary-execution kind), per-DAO treasuries on derived sub-identity addresses with ancestor clawback/freeze powers, and bylaws documents amended by verifiable diff patches. See README.md and the ADRs under gno.land/adr/ for the design record.

Constants 1

const CommonDAOID

1const CommonDAOID uint64 = 1
source

CommonDAOID is the ID of the realm's DAO.

Functions 27

func AmendBylawsPayload

Action
1func AmendBylawsPayload(daoID uint64, path, proposed string) string
source

AmendBylawsPayload builds the CreateAmendBylawsProposal payload that changes a DAO's document at path to the proposed text: a new path adds a document, empty proposed text removes one. It diffs against the document's current text and pins its hash, so build the payload fresh (e.g. through a vm/qeval query) and propose promptly — a payload built against superseded text is rejected. Read-only.

func CreateAmendBylawsProposal

crossing Action
1func CreateAmendBylawsProposal(cur realm, daoID uint64, payload string) uint64
source

CreateAmendBylawsProposal creates a proposal to add, amend or remove one of the DAO's bylaws documents with a verifiable diff patch (see gno.land/p/nt/bylaws/v0). The mandates/ folder is reserved: the Constitution grants a council self-power over its Bylaws only, so mandates change from above (creation or an ancestor's amendment — not implemented yet), never through this proposal. The payload is an encoded patch — build it with AmendBylawsPayload (e.g. through a vm/qeval query) or with bylaws.Diff(...).Encode() from a realm. The patch pins the sha256 of the document text it was diffed against, so an amendment racing a concurrent change to the same document fails cleanly instead of clobbering it; a patch already stale at creation is rejected here. Amendments are decided by supermajority — the default council rule; the Constitution names no special threshold for a council amending its own documents.

Parameters: - daoID: ID of the DAO (required) - payload: encoded bylaws patch (required)

func CreateAncestorCouncilUpdateProposal

crossing Action
1func CreateAncestorCouncilUpdateProposal(cur realm, daoID, targetID uint64, newMembers, removeMembers string) uint64
source

CreateAncestorCouncilUpdateProposal creates a proposal for an ancestor DAO to add and/or remove members of a descendant's council (docs/CONSTITUTION.md :1531-1532) — the rescue path for a stuck or empty descendant council. It is hosted and voted in the ancestor (daoID) and decided by supermajority; the proposing DAO must be a proper ancestor of the target, verified at proposal validation.

Parameters: - daoID: ID of the proposing ancestor DAO (required) - targetID: ID of the descendant DAO whose council changes (required) - newMembers: Newline separated list of addresses to add to the council - removeMembers: Newline separated list of council addresses to remove

func CreateCouncilUpdateProposal

crossing Action
1func CreateCouncilUpdateProposal(cur realm, daoID uint64, newMembers, removeMembers string) uint64
source

CreateCouncilUpdateProposal creates a new proposal to add and/or remove council members.

Parameters: - daoID: ID of the DAO (required) - newMembers: Newline separated list of addresses to add to the council - removeMembers: Newline separated list of council addresses to remove

func CreateDeregisterKindProposal

crossing Action
1func CreateDeregisterKindProposal(cur realm, daoID uint64, kindName string) uint64
source

CreateDeregisterKindProposal creates a proposal to deregister a proposal kind from a DAO by name, through the permanent manage-kinds kind.

The proposal is hosted and voted in the DAO itself and decided by supermajority; on approval the kind is deregistered, which blocks new proposals of that kind while in-flight ones still vote and execute. The manage-kinds kind itself cannot be deregistered, so a DAO always keeps the ability to manage its kind set (and to re-register a catalog kind by name).

Parameters: - daoID: ID of the DAO (required) - kindName: name of the proposal kind to deregister (required)

func CreateDissolutionProposal

crossing Action
1func CreateDissolutionProposal(cur realm, daoID uint64, destination address) uint64
source

CreateDissolutionProposal creates a new proposal to dissolve a DAO or SubDAO.

SubDAOs can only be dissolved by the parent DAO, which owns and controls its sub-DAOs (docs/CONSTITUTION.md :1507). When the parent is itself already dissolved, the proposal is hosted in the nearest non-dissolved ancestor, so orphans below a dissolved middle DAO remain dissolvable.

Dissolution sweeps any remaining treasury balance. A sub-DAO's sweep goes to its parent and destination must be empty; a root DAO has no parent, so a valid destination address is required.

Parameters: - daoID: ID of the DAO to dissolve (required) - destination: sweep destination, root DAOs only

func CreateExecutionProposal

crossing Action
1func CreateExecutionProposal(cur realm, daoID uint64, title, body string, fn commondao.ExecFunc) uint64
source

CreateExecutionProposal creates a proposal that runs an arbitrary ExecFunc as the DAO's own sub on approval, through the realm's execution kind.

The execution kind is opt-in: it is not seeded on new DAOs and must be registered first through a supermajority CreateRegisterKindProposal.

Freeze policy: an execution proposal moves value under the DAO's own authority, so it is subject to the treasury freeze exactly like a spend. This wrapper fails fast when the treasury is already frozen, and the definition re-checks at Execute (so a freeze landing after the proposal passed fails it cleanly, StatusFailed, no funds leaving). An ancestor's clawback/dissolution is a separate power and is not blocked by freeze.

Sharp edges (known limitations):

  • The fn closure cannot be encoded in a CLI transaction, so this wrapper is reachable only from a PERSISTENT realm that imports this one and is a council member of the DAO (a realm-in-council). The closure must be authored in that realm so it survives Propose→Execute; a `maketx run` script's closure does not persist and cannot execute later.
  • A closure that panics or runs out of gas aborts the whole Execute tx, so the proposal is stuck Active (every retry re-aborts) and can never finalize. The only recovery is dissolving the DAO (Dissolve dismisses in-flight proposals). Author closures that return an error instead of panicking so a bad execution fails cleanly (StatusFailed) and releases.

Parameters: - daoID: ID of the DAO (required) - title: proposal title (raw text, escaped when rendered) - body: proposal body (raw text, escaped when rendered) - fn: the closure executed on approval (required, non-nil)

func CreateRegisterKindProposal

crossing Action
1func CreateRegisterKindProposal(cur realm, daoID uint64, kindName string) uint64
source

CreateRegisterKindProposal creates a proposal to register one of the realm's catalog proposal kinds on a DAO by name, through the permanent manage-kinds kind (e.g. register "execution").

The proposal is hosted and voted in the DAO itself and decided by supermajority; on approval the named catalog kind is registered, so new proposals of that kind can be created. The manage-kinds kind is seeded on every DAO, so this path is always available.

Parameters: - daoID: ID of the DAO (required) - kindName: name of the catalog proposal kind to register (required)

func CreateSubDAOProposal

crossing Action
1func CreateSubDAOProposal(cur realm, daoID uint64, name, purpose, description, members string) uint64
source

CreateSubDAOProposal creates a new proposal to create a new SubDAO.

Parameters: - daoID: ID of the parent DAO (required) - name: A name for the SubDAO (required) - purpose: A purpose for the SubDAO (required) - description: A description for the SubDAO - members: Newline separated list of initial SubDAO council addresses (required)

func CreateTextProposal

crossing Action
1func CreateTextProposal(cur realm, daoID uint64, title, body string, votingDays uint8) uint64
source

CreateTextProposal creates a new general text proposal.

Parameters: - daoID: ID of the DAO (required) - title: Title of the proposal (required) - body: Body of the proposal (required) - votingDays: The number of days where proposal accepts votes.

The default voting period is 7 days.

func CreateTreasuryClawbackProposal

crossing Action
1func CreateTreasuryClawbackProposal(cur realm, daoID, targetID uint64) uint64
source

CreateTreasuryClawbackProposal creates a new proposal for an ancestor DAO to sweep a descendant DAO's full treasury balance to the target's parent (docs/CONSTITUTION.md :1507). The proposing DAO must be a proper ancestor of the target; a target's own options can never block an ancestor's clawback.

Parameters: - daoID: ID of the proposing ancestor DAO (required) - targetID: ID of the descendant DAO to claw back (required)

func CreateTreasuryFreezeProposal

crossing Action
1func CreateTreasuryFreezeProposal(cur realm, daoID, targetID uint64, frozen bool) uint64
source

CreateTreasuryFreezeProposal creates a new proposal for an ancestor DAO to freeze or unfreeze a descendant DAO's treasury. While frozen, no treasury spend can execute. Only a proper ancestor can unfreeze — the frozen DAO's own council cannot.

Parameters: - daoID: ID of the proposing ancestor DAO (required) - targetID: ID of the descendant DAO to freeze or unfreeze (required) - frozen: true to freeze the target's treasury, false to unfreeze

func CreateTreasurySpendProposal

crossing Action
1func CreateTreasurySpendProposal(cur realm, daoID uint64, to address, denom string, amount int64) uint64
source

CreateTreasurySpendProposal creates a new proposal to send coins from the DAO's own treasury (docs/CONSTITUTION.md :1542-1543).

Parameters: - daoID: ID of the DAO whose treasury is spent (required) - to: recipient address (required) - denom: coin denomination, e.g. "ugnot" (required) - amount: coin amount, must be positive (required)

func Execute

crossing Action
1func Execute(cur realm, daoID, proposalID uint64)
source

Execute executes a DAO proposal.

Executing a proposal that passed early (decided by the default Council rules before its voting deadline) requires the caller to be a council member. Once the voting deadline has passed execution is permissionless: the tally is deterministic, so anyone can finalize the proposal.

func GetBylawsDoc

Action
1func GetBylawsDoc(daoID uint64, path string) string
source

GetBylawsDoc returns the text of a DAO's bylaws/mandates document, or an empty string when the document does not exist (a stored document is never empty).

func GetView

Action
1func GetView(daoID uint64) commondao.ReadonlyCommonDAO
source

GetView returns a read only view of a common DAO searched by ID.

func HasProposalKind

Action
1func HasProposalKind(daoID uint64, name string) bool
source

HasProposalKind reports whether a proposal kind is registered on a DAO.

func Invite

crossing Action
1func Invite(cur realm, invitee address)
source

Invite invites a user to the realm. A user invitation is required to start creating new DAOs.

func IsInvited

Action
1func IsInvited(addr address) bool
source

IsInvited checks if an address has an invitation to the realm.

func IsListed

Action
1func IsListed(daoID uint64) bool
source

IsListed reports whether a DAO appears in the realm's public home index.

func ListBylawsDocs

Action
1func ListBylawsDocs(daoID uint64, prefix string) []string
source

ListBylawsDocs returns the sorted paths of a DAO's bylaws/mandates documents under a prefix (empty prefix lists all).

func New

crossing Action
1func New(cur realm, name, purpose, description, members string) uint64
source

New creates a new CommonDAO and returns its ID. The caller must be a user, not a realm (see assertCallerIsUser), and must hold an invite. The invite is consumed when that caller creates a DAO for the first time, after which the caller may create further DAOs freely. The caller becomes a council member along with any additional member addresses listed on separate lines; those may be realm addresses, so a DAO can be handed to a realm by seating it here and resigning. DAOs with a parent are created through proposals (see CreateSubDAOProposal).

func Resign

crossing Action
1func Resign(cur realm, daoID uint64)
source

Resign removes the caller from a DAO council. The last remaining council member cannot resign.

func SetListed

crossing Action
1func SetListed(cur realm, daoID uint64, listed bool)
source

SetListed adds or removes a DAO from the realm's public home index. Listing is cosmetic — it affects only how this realm presents the DAO in its own UI — so any single council member of the DAO may toggle it, like Resign. It defaults to off.

func Vote

crossing Action
1func Vote(cur realm, daoID, proposalID uint64, vote commondao.VoteChoice, reason string)
source

Vote submits a vote for a DAO proposal. Voting is allowed to the members of the proposal's electorate: the council snapshot taken when the proposal was created.

func Withdraw

crossing Action
1func Withdraw(cur realm, daoID, proposalID uint64)
source

Withdraw withdraws an active DAO proposal that has no votes. Only the proposal creator can withdraw it.

Types 1

type Funded

interface
1type Funded interface {
2	// FundingDAOID returns the ID of the DAO whose sub-address funds the
3	// executor.
4	FundingDAOID() uint64
5}
source

Funded is the optional contract a proposal definition implements when its executor moves funds from a DAO other than the proposal's host: it names, by ID, the DAO whose sub-identity address funds the executor. Execute resolves that DAO, mints its terminal RealmSend-only sub and passes it to the ExecFunc; a definition that does not implement Funded receives the host DAO's own sub by default. The returned ID must identify the DAO the definition validates its fund movement against (e.g. the DAO being spent, swept or dissolved).

It lives realm-side, not in /p/: minting a DAO sub needs the host realm's cur (cur.Sub), so only the host — never the package — can honor it. /p/ dispatches CapExempt/Executable/Validable itself, but Execute (the host) is the sole consumer of Funded, so the package has no reason to know it.

Imports 22

Source Files 16