Migrations
First Migration
This script will deploy the module’s smart contract.
Open/copy the first migration script called
1_[yourModule].migration.ts
You can use the AirDropV2 script as a starting point.Add your module smart contract as an artifact, by replacing the “AirDropV2” with your Module name.
Make sure to change the import directory in the script to point to the right folder.
import { MODULE_NAME } from "@/deploy/[yourModule]/constants";
Now execute the first Migration:
To run the first migration script, use the command:
npx hardhat migrate --network mainnet --only 1
Note: exchange “mainnet” for “testnet” if applicable, depending on where your DAO lives
Save the contract address of the module you just deployed. It will be displayed in the console. You can add the address to the constants.ts file to “ModuleImplementation” as mentioned earlier
Second Migration
This creates two new voting situations: one for voting on adding modules to the registry and one for managing the module.
Open/copy the second migration script called
2_createModule.migration.ts
You can use the AirDropV2 script as a starting point.Make sure to change the import directorie in the script to point to the right folder.
import { MODULE_NAME, MAIN_DAO_VOTING_ADDRESS, VOTING_CONTRACT_ADDRESS } from "@/deploy/[yourModule]/constants";
import { buildVotingSituation } from "@/deploy/[yourModule]/utils";To run the second migration script, use the command:
npx hardhat migrate --network mainnet --only 2
Note: exchange “mainnet” for “testnet” if applicable, depending on where your DAO lives
Attention! This creates proposals in your DAO.
Go to your DAO Dashboard
hq.q-dao.tools/[0xYourDAORegistryAddress]
and Vote on the two proposals in the governance section of the UI. One is for adding the new voting situation to add new modules and one to add a voting situation to manage the module by voting.
Third Migration
This creates a proposal to add the new module to the DAO Registry
Open/copy the third migration script called 3_add.module.to.registry.migration.ts You can use the AirDropV2 script as a starting point.
Add the new module address (Saved after migration 1) to the
console.ts
file if not done so already.Make sure to change the import directory in the script to point to the right folder.
import { MODULE_IMPLEMENTATION, MODULE_NAME, MAIN_DAO_VOTING_ADDRESS } from"@/deploy/[yourModule]/constants";
To run the third migration script, use the command:
npx hardhat migrate --network mainnet --only 3
Note: exchange “mainnet” for “testnet” if applicable, depending on where your DAO lives.
Attention! For this to work, the previous proposals from migration2 have to have passed and must be executed.
Attention! This creates a proposal in your DAO.
Go to your DAO Dashboard hq.q-dao.tools/[0xYourDAORegistryAddress]
and vote on the proposal in the governance section of the UI.
The proposal adds the new module to the DAO Registry.
Fourth Migration
This script will initialize the module’s smart contract.
Open/copy the first migration script called 4_initialize.module.migration.ts You can use the AirDropV2 script as a starting point.
Add your module smart contract as an artifact, by replacing the “AirDropV2” with your Module name.
const ModuleArtifact = artifacts.require("[YourModule]");
Make sure to change the import directory in the script to point to the right folder.
import { MODULE_NAME, DAO_REGISTRY_ADDRESS, VOTING_CONTRACT_ADDRESS } from"@/deploy/[yourModule]/constants";
Make sure to use the proper initialization Function from your module smart contract (see moduleProxy.__AirDropV2_init(VOTING_CONTRACT_ADDRESS),
Initialize ${MODULE_NAME}
;) This is a function of the module’s smart contract and thus can change based on the module you want to add.Note: depending on your module’s code, you might have to provide more inputs for this function than the votingAddress.
Now execute the fourth Migration:
- To run the first migration script, use the command:
npx hardhat migrate --network mainnet --only 4
Note: exchange “mainnet” for “testnet” if applicable, depending on where your DAO lives.
Congratulations! Now your module is added to your DAO and ready to go!
However currently the Dashboard UI does not yet dynamically support new modules. So to use your module, you have two options:
You can write a new script to create proposals to vote on and manage the module. For an example on how to do this, you can check out the scripts
10_create.campagin.migration.ts
and11_claim.reward.migration.ts
located atmodule-integration-demo/moduleV2
You fork your own UI of the Dashboard and modify it so it supports this voting situation. This makes sense when you intend to use the module regularly. You can find the Code for the Dashboard UI at this link and the helper scripts for proposals at this link.