How to create an autofill proposal link

Proposals and the actions they contain can be generated programmatically and passed in via URL—this enables a more user-friendly experience for users of a specific app or service that rely on DAO DAO for their governance needs.

Similar to the bulk import actions feature, you must find the key and the shape of the data object for each action. However, unlike bulk import, you must also find the proposal module adapter ID, and the action key in the object must be actionKey instead of key.

The link is simply the proposal creation page with a prefill parameter added, like this:

https://daodao.zone/dao/<DAO_ADDRESS>/proposals/create?prefill=<PREFILL_DATA>

The prefill parameter can either be:

  • a stringified JSON object

  • a base64-encoded JSON object

circle-exclamation

The format of the prefill object is always:

{
  "id": "<PROPOSAL MODULE ADAPTER ID>",
  "data": {
    // PROPOSAL MODULE FORM DATA
  }
}

You can use base64encode.orgarrow-up-right to encode the JSON object to a base64 string and urlencoder.orgarrow-up-right to URL-escape the base64 string.

IPFS

The prefill object can get quite large which becomes impractical to use in a URL, so instead you can upload a JSON blob to IPFS and replace the prefill parameter with pi, pointing to the IPFS hash containing the object:

https://daodao.zone/dao/<DAO_ADDRESS>/proposals/create?pi=<IPFS_HASH>

Proposal module adapter ID

The proposal module adapter IDs can be found in @dao-dao/utils/constants/adapters.tsarrow-up-right.

For dao-proposal-single (the most commonly used proposal module that supports proposals with Yes/No/Abstain votes), the ID is DaoProposalSingle. For dao-proposal-multiple (which supports multiple choice proposals), the ID is DaoProposalMultiple.

Proposal module form data

The form data structure can be found in @dao-dao/types/proposal-module-adapter.tsarrow-up-right.

The single choice proposal form dataarrow-up-right is:

The multiple choice proposal form dataarrow-up-right is:

See the bottom of this document for a complete example.

Action keys

The action keys can be found in @dao-dao/types/actions.tsarrow-up-right in the ActionKey enum. For example:

  • spend

  • execute

  • mintNft

  • mint

The key and data format for an action are defined in its README.md, and the actions can be found in the following places:

Here are some common ones:

For sending money from the treasury.

For executing a smart contract.

For minting an NFT in a collection the DAO controls.

For minting governance tokens in a token-based DAO.

Example

Here's an example of a proposal link that creates a single choice proposal with a spend action and an execute action in the DAO DAO DAOarrow-up-right.

Base64-encodingarrow-up-right the entire object:

And then URL-escapingarrow-up-right the base64 string simply replaces the = at the end with %3D:

Using the DAO DAO DAOarrow-up-right address and then adding the prefill parameter to the URL gives us the proposal creation page with the proposal prefilled:

https://daodao.zone/dao/juno10h0hc64jv006rr8qy0zhlu4jsxct8qwa0vtaleayh0ujz0zynf2s2r7v8q/proposals/create?prefill=ewogICJpZCI6ICJEYW9Qcm9wb3NhbFNpbmdsZSIsCiAgImRhdGEiOiB7CiAgICAidGl0bGUiOiAiRXhhbXBsZSBQcm9wb3NhbCIsCiAgICAiZGVzY3JpcHRpb24iOiAiVGhpcyBwcm9wb3NhbCB3aWxsIHNlbmQgMTAwIEpVTk8gdG8gb3VyIGNvbW11bml0eSBmdW5kIGFuZCB1cGRhdGUgb3VyIHZvdGluZyBtb2R1bGUncyB1bnN0YWtpbmcgZHVyYXRpb24uIiwKICAgICJhY3Rpb25EYXRhIjogWwogICAgICB7CiAgICAgICAgImFjdGlvbktleSI6ICJzcGVuZCIsCiAgICAgICAgImRhdGEiOiB7CiAgICAgICAgICAiZnJvbUNoYWluSWQiOiAianVuby0xIiwKICAgICAgICAgICJ0b0NoYWluSWQiOiAianVuby0xIiwKICAgICAgICAgICJmcm9tIjogImp1bm8xMGgwaGM2NGp2MDA2cnI4cXkwemhsdTRqc3hjdDhxd2EwdnRhbGVheWgwdWp6MHp5bmYyczJyN3Y4cSIsCiAgICAgICAgICAidG8iOiAianVubzFjb21tdW5pdHkuLi5mdW5kNDU2IiwKICAgICAgICAgICJhbW91bnQiOiAiMTAwIiwKICAgICAgICAgICJkZW5vbSI6ICJ1anVubyIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIHsKICAgICAgICAiYWN0aW9uS2V5IjogImV4ZWN1dGUiLAogICAgICAgICJkYXRhIjogewogICAgICAgICAgImNoYWluSWQiOiAianVuby0xIiwKICAgICAgICAgICJzZW5kZXIiOiAianVubzEwaDBoYzY0anYwMDZycjhxeTB6aGx1NGpzeGN0OHF3YTB2dGFsZWF5aDB1anowenluZjJzMnI3djhxIiwKICAgICAgICAgICJhZGRyZXNzIjogImp1bm8xdm90aW5nLi4ubW9kdWxlNzg5IiwKICAgICAgICAgICJtZXNzYWdlIjogIntcInVwZGF0ZV9jb25maWdcIjp7XCJkdXJhdGlvblwiOjg2NDAwfX0iLAogICAgICAgICAgImZ1bmRzIjogW10KICAgICAgICB9CiAgICAgIH0KICAgIF0KICB9Cn0%3Darrow-up-right

Last updated