Generic Schemes¶
In DAOstack, "schemes" are smart contracts that enable various DAO actions, and "generic schemes" are schemes that enable nearly any kind of action possible for an Ethereum address.
DAOs can use GenericScheme:
- to enable truly generic DAO actions (letting proposers choose which contracts to interact with and how),
- to create specific, custom integrations (actions that make particular calls to particular smart contracts that serve a particular purpose for the DAO).
NOTE:
- If a DAO wants to make multiple smart contracts available, with different labels and proposal types in the UI, then each contract should use its own GenericScheme instance, customized if required for the DAO's purpose.
- While at the contract level, generic schemes only need encoded call data to function, asking users to provide this data is not good UX. If you're using a generic scheme for anything except a truly generic action, which is only accessible to Ethereum experts, we ask that you add Alchemy support for the specific actions you intend. Please do not register your scheme on mainnet without adding alchemy support for it. Here is an example of a customized generic scheme on mainnet.
- UGenericScheme i.e. the universal version of the generic scheme has been deprecated and removed from arc ( version > 33). Subgraph and Alchemy will be backward compatible and support old DAOs already deployed and using it.
How to register a Generic Scheme to a DAO¶
A DAO can only use schemes that are registered with its controller. There are two ways to register a scheme to a DAO's controller:
-
During the DAO's creation, while deploying the DAO's contracts
-
Through a proposal that uses a scheme with permission to register schemes to the DAO.
NOTE: In case of the Genesis DAO, you can propose new schemes to be registered using the aptly named Scheme Registrar scheme.
Register a Generic Scheme while deploying a DAO¶
While deploying DAO you can register multiple "GenericScheme" instances and mention each in the
customSchemes
section of your migration-dao-params.json
.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Refer to the instructions for how to deploy DAO.
Register Generic Scheme to an already deployed DAO¶
If the DAO has a Scheme Registrar scheme, then you can register new schemes to DAO via a proposal.
Registering a new scheme via registrar requires: - Set voting Machine Parameters (if other than already saved) - Submit proposal to Scheme Registrar
Set Voting Machine Parameters¶
If your Generic Scheme use vote parameters other than the ones already registered with Genesis Protocol (voting machine), then use setParameter
to register new vote parameters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
Set Generic Scheme to interact with your contract¶
Now, you will have to deploy a new instance of GenericScheme
and use its initialize
method to setup its params:
- the DAO
Avatar
it connects to, - the
contractToCall
, - the
votingMachine
to use, - the
voteParameters
for voting on proposals that use the scheme (taken from the previous step).
The following is a short script that shows how to do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
Submit a new proposal to the Scheme Registrar via Alchemy UI¶
- On Alchemy's landing page, choose the DAO to which you wish to register the scheme.
- Visit the DAO's
Home
page and chooseScheme Registrar
. - Click
New Proposal
– this will open a popup. - Select
Add Scheme
on the popup sidebar (on the left). - Give the proposal an appropriate title, description, and url linking to a description of the proposal.
- For
Scheme
, put the address of your Generic Scheme contract. - The
paramHash
can be null for non universal scheme. - In the permissions section, check
Call genericCall on behalf of
(this will allow your scheme to make generic calls, which is the whole point here). - Submit the proposal and sign the transaction as normal.
- If the DAO passes your proposal, then your Generic Scheme with the ability to interact with the
targetContract
will be registered to the DAO, and people will be able to submit proposals for the DAO to take your custom generic action.
How to get Generic Scheme indexed by DAOstack subgraph¶
The DAOstack subgraph enables Alchemy's quick loading of cached blockchain data and is a huge part of creating a positive user experience in Alchemy.
You will have to submit a PR here
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
How to get your Generic Scheme showing up in Alchemy¶
To help you get a user-friendly interface for your generic scheme, we have created a way to customize Alchemy's UI for specific generic schemes.
The customization has a few pieces, and you will have to submit a PR to the Alchemy repo once you're finished with it.
Proposal Creation Interface¶
Customize the "create proposal" popup to present the different functions the scheme can call on the contract. This requires adding the contracts’ ABI and customizing things like the titles of the labels and placeholders.
If this was a generic scheme for interacting with the Bounties Network, you would create a file named something like Bounties.json
and add it here.
Use the following example or refer to an example using the DutchX integration.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
Update Known Schemes¶
Once you have customised the proposal create interface update the genericSchemeRegistry
For eg. In case of StandardBounty scheme we will add:
1 2 3 4 5 6 |
|
Proposal Display Interface¶
You will also have to customise the description summary for your scheme to explain what it does.
Refer to the ProposalSummaryDutchX and add your own proposal summary file, say ProposalSummaryBountiesNetwork.tsx
, here.
Update Proposal Summary render¶
Once you have created the proposal summary make sure that it gets rendered by updating ProposalSummaryKnownGenericScheme.tsx
For eg. In case of StandardBounty scheme we will add:
1 2 3 4 |
|
Integration tests¶
Please add the relevant integration test for your scheme. You can refer to genericSchemeDutchx tests.
(Optional) Change the Scheme UI¶
Right now, Alchemy’s UI is only focused on currently open proposals (it does not show past proposals). But based on the scheme you are adding, there might be some different UI features/tabs that are required. For a bounties scheme, for example, it would be helpful to have a new tab that shows open bounties (from proposals that have already been passed).