# Mint a Million Boost Tutorial > This tutorial will show you to create a DAOhaus Boost that interacts with a Smart Contract Creating a DAOhaus Boost is a way to add functionality to the [DAOhaus Interface](app.daohaus.club). This tutorial will show you how to create a Contract Boost. Contract Boosts enable your DAO to initiate an interaction with an external contract. See the ==[DAOhaus Proposal Process]()== for more information about how proposals work in the DAOhaus app. This "Mint a Million" Contract Boost will allow a DAO to create an ERC-20 token with 1 million supply using a [Factory Contract](https://rinkeby.etherscan.io/address/0xe4E893AffD33dDED43ECdf8bBC550639c84485e5#code) we have supplied for you. The token will be managed by a Minion and Safe in your DAO. ::: info Learn more about ==[Minions & Safes]()== ::: # Contract Boost Overview To build a Contract Boost, there are 3 primary components you'll need to create: 1. **Form:** The form used to collect data from the proposer that is needed to execute the external contract interaction. 2. **Contract:** The contract address and the Applicaton Binary Interface (ABI) provided by the contract. 3. **Transaction Schema:** The data to send to the contract when the proposal passes. For more information on how Boosts work, refer to the ==[Overview page here]()== Resources: * [Youtube Video Walkthrough](https://youtu.be/Xk1nETEvuJw) * [Completed Tutorial Code](https://github.com/HausDAO/daohaus-app/pull/1819/files) # Getting Started **Before you begin,** * Follow these steps to clone the [daohaus-app github repo](https://github.com/HausDAO/daohaus-app) and create a branch with the format ```mint_a_million_<yourdiscordhandle>```. *Your discord handle in the branch name helps us when providing support.* * ```git clone https://github.com/HausDAO/daohaus-app.git``` * ```cd daohaus-app``` * ```git branch mint_a_million_yourhandle``` * ```git checkout mint_a_million_yourhandle``` * ```touch .env``` * Open the `.env` file you just created in your root directory and add the following: ``` g GENERATE_SOURCEMAP=false REACT_APP_DEV=true ``` * *REACT_APP_DEV=true* will give you access to debugging screens that are not normally visible in the DAOhaus app ==Do we need the Infura Project ID, RPC URI?== ==What does generate_sourcemap do?== From the root of your application: * Run `yarn install` to install dependencies * Run `yarn start` to launch the DAOhaus app For guidelines on contributing to DAOhaus repositories, refer to the ==[Contributing Guidelines here]()== # Step 1: Build your Form ([31:52](https://youtu.be/Xk1nETEvuJw?t=1912)) In this step, we will set up your Contract Boost's proposal form and fields that are required to create the proposal and execute the external contract call. ==As it stands, these tutorial branches can't be merged because there would be filename collisions== ==Question: Actually following this tutorial will lead to duplicate files if pushed and merged. Maybe we want to modify this to add their boost to a "Tutorial Playlist" that automatically creates a token of their choosing... some modification could end up with a long list of slightly different summon token boosts, which would be pretty cool== ## Step 1.1: Create **[mintAMillionForms.js](https://github.com/HausDAO/daohaus-app/pull/1819/files#diff-b7c92f30157b49e73f304e34c7c3d54cdd30d0908029a0b0b7fe1be85e476c3d)** in `src/data/formLegos/` for your Boost This file will export a single javascript object that the DAOhaus App will use to generate the form for your boost. Though it is possible to specify multiple forms in one file, in this case there is just one form called `SUMMON_TOKEN` Add the following code to mintAMillionForms.js: ```jsx title="/src/data/formLegos/mintaMillionForms.js" import { MINION_TYPES, PROPOSAL_TYPES } from '../../utils/proposalUtils'; import { FIELD } from '../fields'; import { TX } from '../txLegos/contractTX'; export const MILLION_FORMS = { SUMMON_TOKEN: { id: 'SUMMON_TOKEN', title: 'Mint A Million', description: 'Mint a million of a new token!', type: PROPOSAL_TYPES.MINT_A_MILLION, // Custom proposal types that allow you to render custom proposal UIs ?? minionType: MINION_TYPES.SAFE, // Selects only the "Safe Minion" dev: true, // Shows the Proposal on your DEV Test List for testing logValues: true, // Logs form values in the console tx: null, // Will build this in step 2 required: [], // Specifies required fields from the below fields fields: [], // Specifies fields to be shown on the form }, }; ``` The `dev: true` will let you see your form in the 'DEV Test List' playlist - a special playlist used for testing. It will be visible only because you added *REACT_APP_DEV=true* to your *.env* file above. > Playlists are groupings of proposals that are related to one another. For instance, the DEV Test List playlist will display all the proposal types in the development environment. This allows you to access and test the proposal before it is complete. To preview your Proposal Playlist, you will need to have an existing DAO locally. If you have not already summoned a DAO, you can summon one at localhost:3000/summon First, ```yarn start``` and Load the app at [http://localhost:3000](http://localhost:3000). Navigate to your DAO and click on **New Proposal**. Select **Manage** on the Proposal Playlist modal. ![](https://i.imgur.com/HDK5vOx.png) You should be able to see a Playlist called "DEV Test List" with the "Mint a Million" Proposal type. ([51:32](https://youtu.be/Xk1nETEvuJw?t=3093)) ![](https://i.imgur.com/p7bkwV5.png) ## Step 1.2: Add a new Proposal Type in `src/utils/proposalUtils.jsx` Add `MINT_A_MILLION: 'Mint a Million',` to the `PROPOSAL_TYPES` object in `src/utils/proposalUtils.jsx`(see line 66). `proposalsUtils.js` is the central directory for all proposal utilities available in the DAOhaus app. This step signals to the DAOhaus App that it should consider your boost proposal as a valid proposal type. ==Are we sure this needs to come before the form is made?== ```jsx=31 ... export const PROPOSAL_TYPES = { CORE: 'Core', MEMBER: 'Member Proposal', SIGNAL: 'Signal Proposal', ... SWAPR_STAKING: 'Swapr Staking Proposal', POSTER_RATIFY: 'Ratify Content', POSTER_RATIFY_DOC: 'Ratify DAO DOC', MINT_A_MILLION: 'Mint a Million', }; ... ``` ## Step 1.3: Add Fields When creating the form, we need to create fields to collect data from users that will be used to initiate the contract call. In this form, we will include: 1. A `Select a Minion` field for DAO members to indicate the address that owns the newly minted ERC-20 tokens 2. A `Token Name` field for the token's name (e.g `My Cool Token`) 3. A `Token Symbol` field for the token's symbol (e.g. `MCT`) ### 1.3.1 Add `FIELD.MINION.SELECT` as the first field ([49:58](https://youtu.be/Xk1nETEvuJw?t=2998)) In `mintAMillionForms.js` add a minion select field to your fields array: ```jsx ... fields: [ // Specifies fields to be shown on the form [FIELD.MINION_SELECT], ], ... ``` `FIELD.MINION_SELECT` is a prebuilt form field that provides a dropdown with all of your DAO's minions. This field will give us access to the Safe Minion address, which we will need to construct our transaction in Step 3. ### 1.3.2 Create a custom field for Token Name and Symbol Modify `mintAMillionForms.js` to add these custom fields to your fields array: ``` jsx ... fields: [ [ // Specifies fields to be shown on the form [FIELD.MINION_SELECT], ], [ { type: 'input', // Standard HTML input label: 'Token Name', // Renders this as form title name: 'tokenName', // This is how the field will be referenced across files htmlFor: 'tokenName', placeholder: 'Token Name', // Placeholder text expectType: 'any', // Type check (e.g. 'number') }, { type: 'input', label: 'Token Symbol', name: 'tokenSymbol', htmlFor: 'tokenSymbol', placeholder: 'Token Symbol', expectType: 'any', }, ], ], ... ``` While there are many field types within the DAOhaus App that can be reused in your form, in this case will make custom form fields to collect the token name and the token symbol. **A Note on Form Columns:** Note that the `fields` array includes a subarray, which holds the form fields. If you would like to create a form with multiple columns, include multiple subarrays, one for each column, within the `fields` array. Form elements that you put in these separate subarrays will appear in seaprate columns. For more information on Form Legos, refer to ==[Form Legos]()== ==TODO ask Jord what htmlFor does in code snippet above== ### 1.3.3 Make all fields required For this form, we need DAO members to fill in all three fields (i.e. Select a Minion, Token Name & Token Symbol). Add the `name` property of each field into the `required` array. If the user does not provide these fields, the form will not be submitted. Your completed `mintAMillionForms.js` file should look like this. ```jsx title="/src/data/formLegos/mintaMillionForms.js" import { MINION_TYPES, PROPOSAL_TYPES } from '../../utils/proposalUtils'; import { FIELD } from '../fields'; import { TX } from '../txLegos/contractTX'; export const MILLION_FORMS = { SUMMON_TOKEN: { id: 'SUMMON_TOKEN', title: 'Mint A Million', description: 'Mint a million of a new token!', type: PROPOSAL_TYPES.MINT_A_MILLION, minionType: MINION_TYPES.SAFE, dev: true, logValues: true, tx: TX.SUMMON_TOKEN, required: ['tokenName', 'tokenSymbol', 'selectedMinion'], fields: [ [ FIELD.MINION_SELECT, { type: 'input', label: 'Token Name', name: 'tokenName', htmlFor: 'tokenName', placeholder: 'Token name', expectType: 'any', }, { type: 'input', label: 'Token Symbol', name: 'tokenSymbol', htmlFor: 'tokenSymbol', placeholder: 'Token Symbol', expectType: 'any', }, ], ], }, }; ``` <!--**fields.js** * Lets us create a field w/validation * expectType: * 'number' will require input be a number * 'any' allows any, etc example: ``` N NFT_PRICE: { type: 'input', label: 'Price', name: 'price', htmlFor: 'price', placeholder: '0', info: INFO_TEXT.NFT_PRICE, expectType: 'number', modifiers: ['addWeiDecimals'] } ```--> ## Step 1.4: Import and add `MILLION_FORMS` object to `src/data/formLegos/forms.js` First, import the `MILLION_FORMS` object in `forms.js`. Add `import { MILLION_FORMS } from './mintAMillionForms';` to the list of imports Next add `...MILLION_FORMS` to the `FORM` object. `forms.js` is the central directory for all forms available in the DAOhaus app. This step imports and stores the `MILLION_FORMS` object (i.e. Mint a Million form formats) in the central directory. ```jsx import { CLASSIC_FORMS } from './classics'; ... import { POSTER_FORMS } from './posterForms'; import { MILLION_FORMS } from './mintAMillionForms'; //ADD THIS export const FORM = { ...CLASSIC_FORMS, ... ...POSTER_FORMS, ...MILLION_FORMS, //AND THIS }; ``` ## Step 1.5: Preview your form Now that you have created your form and added it to the DAOhaus App, you can preview it in the `DEV Test List` playlist. To preview the form in your development environment, navigate to the `DEV Test List` by clicking on Proposals > New Proposal > Manage(Gear Icon) > DEV Test List. > Again, you will need to have an existing DAO to preview your Proposal Playlist. If you have not already summoned a DAO, you can summon one at localhost:3000/summon ==We went into this earlier, but maybe we don't say anything until now when they can see it== The test "Mint a Million" proposal is now visible in the `Dev Test List` ([51:32](https://youtu.be/Xk1nETEvuJw?t=3093)) because we set these properties: * `dev: true` (in `mintAMillionForms.js`) * `REACT_APP_DEV=true` (in `.env`) http://localhost:3000/dao/0x4/0xba91c92c3fcd67b8e29596cb2a49f418f7715142/settings/proposals # Step 2: Import your Contract Now that your proposal form is ready, let's set up the contracts that your Boost will be interacting with. ## Step 2.1: Add your contract address in `src/utils/chain.js` The `chain.js` file stores all the contract addresses that the application needs to have access to. Contract addresses are separated by network chains (e.g. Ethereum Mainnet, Rinkeby, etc.) Our contract exists on Rinkeby, so we will add the contract address to the Rinkeby object. The Mint a Million Contract address is `0xe4E893AffD33dDED43ECdf8bBC550639c84485e5` Add `erc20_summon:'0xe4E893AffD33dDED43ECdf8bBC550639c84485e5',` to the `'0x4'` (i.e. Rinkeby) object. Your field can technically be added anywhere in the object, but let's add it after the `moloch_factor_addr` in `chain.js` field to keep things organized: ``` jsx '0x4': { name: 'Ethereum Rinkeby', short_name: 'rinkeby', shortNamePrefix: 'rin', nativeCurrency: 'ETH', network: 'rinkeby', network_id: 4, chain_id: '0x4', ... minion_factory_addr: '0x313F02A44089150C9ff7011D4e87b52404A914A9', moloch_factory_addr: '0xC33a4EfecB11D2cAD8E7d8d2a6b5E7FEacCC521d', erc20_summon: '0xe4E893AffD33dDED43ECdf8bBC550639c84485e5', // Our contract address ... } ``` ## Step 2.2: Create a new object in `src/data/contracts.js` Open `src/data/contract.js` and add the following `ERC_20_SUMMON` object to the CONTRACTS object: ``` jsx export const CONTRACTS = { ... ERC_20_SUMMON: { location: 'local', abiName: 'ERC_20_SUMMON', contractAddress: '.contextData.chainConfig.erc20_summon', }, ... } ``` The DAOhaus application uses a `.` search notation to point to data / properties within objects in the codebase. For instance, the `contractAddress: '.contextData.chainConfig.erc20_summon',` will point to the `erc20_summon` property within the `chainConfig` object that you added in ==Step 2.1== above ## Step 2.3: Create a new JSON file in `src/contracts` called [erc20Summon.json](https://github.com/HausDAO/daohaus-app/pull/1819/files#diff-f2074041d89d84186ebb17c25d819247a85a04a7cce7cfefde67b9f4700e3eee) ([1:07:33](https://youtu.be/Xk1nETEvuJw?t=4053)) ## Step 2.4: Add contract ABIs to `erc20Summon.json` First, navigate to the [Mint a Million contract](https://rinkeby.etherscan.io/address/0xe4E893AffD33dDED43ECdf8bBC550639c84485e5#code) on Etherscan. Next, copy and paste the ABIs for this contract by clicking the 'Copy All to clipboard' button in the Contract ABI section. Paste the Contract ABI into erc20Summon.json ![](https://i.imgur.com/Znp7wuA.png) These ABIs will be used by the DAOhaus app when creating a transaction and interacting with the smart contract's available functions. ## Step 2.5: Import the contract ABIs into `src/utils/abi.js` ([1:08:10](https://youtu.be/Xk1nETEvuJw?t=4090)) The `abi.json` file is a central directory of all contract ABIs which the DAOhaus app will interact with. This step imports and stores the `ERC_20_SUMMON` object (i.e. Mint a Million Factory contract ABIs) into the central directory. Open `src/utils/abi.js` and add the following 2 lines: `import ERC_20_SUMMON from '../contracts/erc20Summon.json'` `ERC_20_SUMMON,` The resulting file should look something like this: ``` jsx import { encodeMultiSend } from '@gnosis.pm/safe-contracts'; import Web3 from 'web3'; import { Contract, BigNumber } from 'ethers'; ... import MOLOCH_TOKEN_FACTORY from '../contracts/molochTokenFactory.json'; import ERC_20_SUMMON from '../contracts/erc20Summon.json' // ADD THIS ... export const LOCAL_ABI = Object.freeze({ MOLOCH_V2, ERC_20, VANILLA_MINION, ... MOLOCH_TOKEN_FACTORY, ERC_20_SUMMON, // AND THIS ... ``` Verify that the `ERC_20_SUMMON` property matches in both `src/utils/abi.js` and `src/data/contracts.js` ## Step 2.6: Create a new Proposal Type in `src/data/details.js` Add the following code to the `DETAILS` object ``` jsx MILLION: { title: `Mint a Million!!!`, proposalType: '.formData.type', }, ``` The `title` object will determine the Proposal title on the Proposal Card within the DAOhaus app. The `proposalType` object will reference the proposal type, which appears in different places in the DAOhaus UI. `.formData.type` references the fields you added to `src/utils/proposalUtils.jsx` earlier in the tutorial. ![](https://i.imgur.com/c176gwk.png) At the end of this step, you have done the necessary set up for your contracts within the DAOhaus app. The next step will be to build and test your transaction! # Step 3: Build your Transaction ## Step 3.1: Create `millionTx.js` in `src/data/txLegos` ([1:11:45](https://youtu.be/Xk1nETEvuJw?t=4305)) First, create a new file called `millionTx.js` in `src/data/txLegos` Next, add the following code into the `MILLION_TX` object. ==Is it the case that this matches the SUMMON_TOKEN we put in the form above? These details will be important when people want to make their own custom boost== ```jsx import { buildMultiTxAction } from '../../utils/legos'; import { CONTRACTS } from '../contracts'; export const MILLION_TX = { SUMMON_TOKEN: buildMultiTxAction({ // TODO actions: [ { targetContract: '.contextData.chainConfig.erc20_summon', // Location for Contract Address (Added in the previous step) abi: CONTRACTS.ERC_20_SUMMON, // Contract ABI (Added in the previous step) fnName: 'summonToken', // Function name in ABI args: [], }, ], }), }; ``` ## Step 3.2 Add your transaction arguments Recall that we pasted these fields into the `erc20Summon.json` file after copying them from the Contract ABI section on Etherscan: ```json "inputs": [ { "internalType": "uint256", "name": "supply", "type": "uint256" }, { "internalType": "string", "name": "name", "type": "string" }, { "internalType": "string", "name": "symbol", "type": "string" }, { "internalType": "address", "name": "receiver", "type": "address" } ``` In our new file `millionTx.js` we need to specify the arguments for the transaction in the same order as they are defined by the Contract ABI. Add the following arguments to the `args` property in `millionTx.js`: ```jsx args: [ '1000000000000000000000000', // Supply (Hardcoded to 1 million in Gwei) '.values.tokenName', // Token Name '.values.tokenSymbol', // Token Symbol '.values.selectedSafeAddress', // Safe Address as the owner ], ``` The DAOhaus app uses React Hooks in its forms, which returns form inputs in an object called `values`. In the above example we specified a hardcoded value of 1000000000000000000000000 for the first property. For the next 3 properties we used dot notation to extract the values provided by the users of the form. In this way we can collect the Token Name, Token Symbol and Selected Safe Address respectively. Selected Safe Address is made available by the MINION_SELECT form field we specified in step ==1.3.1== When building the transaction, the above values will be submitted as a part of the transaction. This will mint 1,000,000 tokens with name and symbol specified by the user, specificing the Minion Safe as the owner. ## Step 3.3 Add the proposal's `detailstoJSON` reference Import the `DETAILS` object into `millionTX.js`: ```jsx import { DETAILS } from '../details'; ``` Add the following property to the `SUMMON_TOKEN` object: ``` jsx detailstoJSON: DETAILS.MILLION, ``` The detailstoJSON property refers to the JSON object added to `details.js` (==Step 2.6==) which contains all proposal details required for rendering proposals (e.g. title, description, etc.) At the end of this step, your code in `millionTX.js` should look like this ``` jsx= import { buildMultiTxAction } from '../../utils/legos'; import { CONTRACTS } from '../contracts'; import { DETAILS } from '../details'; export const MILLION_TX = { SUMMON_TOKEN: buildMultiTxAction({ actions: [ { targetContract: '.contextData.chainConfig.erc20_summon', abi: CONTRACTS.ERC_20_SUMMON, fnName: 'summonToken', args: [ '1000000000000000000000000', '.values.tokenName', '.values.tokenSymbol', '.values.selectedSafeAddress', ], }, ], detailsToJSON: DETAILS.MILLION, }), }; ``` ## Step 3.4: Import the MILLION_TX object into `src/txLegos/contractTX.js` First, add the following code to import the `MILLION_TX` object. ```jsx import { MILLION_TX } from './millionTX'; ``` Next, add ```jsx ...MILLION_TX, ``` to the `TX` object in `src/txLegos/contractTX.js`. Once this step is complete, you are ready to test your transaction to mint a million tokens. Navigate to your Proposals and submit a Mint a Million Proposal to test your Boost! # ==Step 4: TBD== ==Have them submit a PR? We won't be able to merge them but we could have a list of tutorial PRs that people have made.== Checklist for submitting a boost: how many transactions and forms How do you want to package this Do you want it all in one group/playlist --- # Appendix / Remove if unnecessary ### Debugging output ([53:26](https://youtu.be/Xk1nETEvuJw?t=3206)) * React hook forms is a library that helps w/React forms, helps with performance through "refs" * DAOhaus wraps React Hook Form * logValues: true (in mintAMillionForms.js) * logs our react hook form values (state of form) to console * logs the "values" object * updates on every keystroke * allows us to see what changes when we do something ### Other Boost Rails - Ease complexity costs that community developers should have to spend on the boosts - Focus on Building Forms, Contracts & Transactions - Team will wire together the boost for you ---