<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Natacha De la Rosa on Medium]]></title>
        <description><![CDATA[Stories by Natacha De la Rosa on Medium]]></description>
        <link>https://medium.com/@delarosa.natacha?source=rss-9f2385c5ee63------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*T-E34mR3GZ9Kg3VQR66w1Q.jpeg</url>
            <title>Stories by Natacha De la Rosa on Medium</title>
            <link>https://medium.com/@delarosa.natacha?source=rss-9f2385c5ee63------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 09:09:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@delarosa.natacha/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Probando tus aplicaciones descentralizadas]]></title>
            <link>https://medium.com/@delarosa.natacha/probando-tus-aplicaciones-descentralizadas-61e98d40993a?source=rss-9f2385c5ee63------2</link>
            <guid isPermaLink="false">https://medium.com/p/61e98d40993a</guid>
            <dc:creator><![CDATA[Natacha De la Rosa]]></dc:creator>
            <pubDate>Mon, 10 Oct 2022 18:58:46 GMT</pubDate>
            <atom:updated>2022-10-10T18:58:46.408Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A9nTfjcoOHZykfB3-8_mvw.png" /><figcaption>header</figcaption></figure><p>En este post vamos a aprender a cómo realizar las pruebas de nuestras aplicaciones descentralizadas.</p><h3>Pre-requisitos</h3><ul><li><a href="https://nodejs.org/en/">Node (NPM)</a></li><li><a href="https://code.visualstudio.com/">VS Code </a>(O editor de preferencia)</li><li><a href="https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity">Solidity</a> plugin (Si usas VS Code)</li><li>Conocimientos de Javascript</li><li>Conocimientos de Solidity</li></ul><h3>Primer paso</h3><p>Primero vamos a crear nuestra aplicación que contenga el backend y el frontend. Para eso usaremos create-web3-dapp del equipo de Alchemy este CLI nos permitirá crear rápidamente nuestra aplicación, para ellos vamos a la terminar y corremos:</p><p>npx create-web3-dapp testing-your-dapp</p><p>Nos va a pedir que nombremos nuestro proyecto, al nombrarlo y presionar enter, nos solicitara como queremos que nuestro proyecto sea creado, vamos a seleccionar create a default EVM application:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*CRbniMfW7pAXkNqs9lR2iw.png" /><figcaption>selección create-web3-dapp</figcaption></figure><p>Luego nos va a preguntar si queremos importar un ambiente de blockchain, vamos a seleccionar Yes , luego nos preguntara que ambiente de desarrollo queremos seleccionar y vamos a seleccionar Hardhat:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MABb7QRgxiJhX4v-pTgNgw.png" /><figcaption>selección create-web3-dapp</figcaption></figure><p>Luego nos va a preguntar si queremos agregar un nuevo smart contract y seleccionamos Yes , luego nos pide el nombre de nuestro contrato, yo seleccione MyNFTToken , dejamos el symbol especificado por defecto para el contrato y luego nos pregunta cual tipo de contrato deseamos crear, seleccionamos ERC721:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B57zlBy7l3pgVYTxNcmvfQ.png" /><figcaption>selección create-web3-dapp</figcaption></figure><p>Seleccionamos la opción de Auto Increment de los features y dejamos el API Key por defecto de Alchemy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YFc8jAS5G48wNLYzYnLT6Q.png" /><figcaption>selección create-web3-dapp</figcaption></figure><p>Luego de realizar esta selección iniciará las instalación de los paquetes necesarios y también actualizará aquellos paquetes que lo necesiten.</p><p>Cuando este proceso se complete, podemos cambiar al directorio de nuestra aplicación: cd testing-your-dapp</p><p>Y abrir el proyecto en nuestro editor de preferencia, en mi caso VSCode.</p><h3>Segundo Paso — Pruebas unitarias del contrato</h3><p>En nuestro proyecto tendremos los siguientes folders:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*rZsVmAHX6AxHYCKUZzI66A.png" /><figcaption>Estructura de la carpeta</figcaption></figure><p>Iniciaremos entrando al folder de backend/, en este folder veremos varias carpetas, para este tutorial nos vamos a centrar en las carpetas de contracts/ y test/en la carpeta de contracts/ veremos nuestro smart contract, que debe verse así:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ec17bc10c2d76dc96196f75030493e7/href">https://medium.com/media/7ec17bc10c2d76dc96196f75030493e7/href</a></iframe><p>Ahora vamos a trabajar las pruebas unitarias de nuestro Smart Contract.</p><p>Las pruebas unitarias de nuestro smart contract pueden escribirse usando Javascript o Solidity, cual vamos a utilizar dependerá del ambiente de blockchain que hayamos seleccionado, en nuestro caso Hardhat nos permite escribir nuestras pruebas utilizando Javascript.</p><p>Esto representa ciertas ventajas para nosotros ya que a la hora de implementar estas funcionalidades en nuestro frontend, las pruebas que creamos usando Javascript pueden servirnos de guía.</p><p>Las pruebas utilizan la librería de <a href="https://www.chaijs.com/">chai</a> esta librería nos brinda diferentes interfaces con las cuales podemos validar la funcionalidad de nuestro contrato.</p><p>Nos dirigimos a la carpeta de test/ en esta carpeta vamos a ver un archivo generado llamado Lock.js vamos a eleminar este archivo.</p><p>Ahora vamos a crear nuestro tests para realizar las pruebas a nuestro contrato, primero vamos a crear un archivo y lo vamos a llamar MyNFTToken.js en este archivo vamos a agregar lo siguiente:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/67d57ae306497d5fef4546c211a62160/href">https://medium.com/media/67d57ae306497d5fef4546c211a62160/href</a></iframe><p>Luego de tener estos cambios, abrimos la consola, navegamos a la carpeta de backend y podemos correr nuestras pruebas usando el siguiente comando en la consola:</p><p>npx hardhat test</p><p>Si ves un error parecido al siguiente:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4pQ7KdWWwpKniScCS4DEpg.png" /><figcaption>Error de configuración de Hardhat</figcaption></figure><p>Puede que nuestra configuración de hardhat este incorrecta, para resolverlo debemos validar que nuestro archivo hardhat.config.js se vea así:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6c12be50b71fecf55cc66beaa3e508e/href">https://medium.com/media/f6c12be50b71fecf55cc66beaa3e508e/href</a></iframe><p>Ahora si podemos volver a ejecutar nuestro comando para los tests:<br>npx hardhat test</p><h3>Tercer Paso — Pruebas en el Frontend</h3><p>Lo primero que vamos a hacer es conectar nuestro fronted con nuestro contrato, para ello vamos a iniciar iniciando un nodo para correr nuestro contracto de manera local. Para esto vamos a abrir una pestaña nueva en nuestra terminal o abrir una nueva terminal, en ella vamos a asegurarnos que estamos en la carpeta backend, si es asi entonces vamos a ejecutar el siguiente comando:</p><p>npm run node</p><p>Con este comando estamos iniciando un nodo local, es nuestra blockchain privada, la cual incluye cuentas con ETH de prueba que podemos utilizar, tenemos acceso a las address y a las claves privadas de estas cuentas, debe verse así:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EvHtDqtfDl7FxAJyLyvIwA.png" /><figcaption>nodo local</figcaption></figure><p>En otra terminal podemos entonces desplegar nuestro contrato, para que podamos utilizarlo en nuestro frontend, nota que debemos estar en la carpeta backend ejecutamos el comando siguiente:</p><p>npm run deploy-local</p><p>Este comando nos dará como resultado la address o dirección de nuestro contrato</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*XDKCUhyBp-JiT9r5v5EjBQ.png" /><figcaption>Contracto desplegado</figcaption></figure><p>Luego de que tenemos nuestro contracto desplegado, guardamos la address de nuestro contrato porque la vamos a utilizar más adelante.</p><p>Ahora en esta misma terminal nos cambiamos a la carpeta frontend, aquí vamos ejecutar el siguiente comando:</p><p>npm run dev</p><p>Con este comando vamos a inicializar nuestra aplicación frontend, la cual se estará ejecutando en la siguiente url:</p><p><a href="http://localhost:3000/">http://localhost:3000</a></p><p>Ahora vamos a añadir a nuestra aplicación frontend la funcionalidad de comprar un token de nuestro smart contract.</p><p>Vamos a concentrarnos en las carpetas components y utils que se encuentran en frontend/pages</p><p>En la carpeta utils abriremos el archivo llamado walletSetup.js y en la linea numero 10 de este archivo vamos a ver un arreglo que contiene todas las chains que esta aplicación soporta, al final del arreglo vamos a agregar una chain adicional, esta es chain.hardhat , después de agregarlo debe verse así:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7591e8084497c1f79ac70bb0f3fbfed1/href">https://medium.com/media/7591e8084497c1f79ac70bb0f3fbfed1/href</a></iframe><p>Ahora debemos importar una de nuestras cuentas de prueba a Metamask, para ello debemos abrir Metamask, estar logeados y hacer click en el Blockie de la cuenta y seleccionar importar cuenta o (import account):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*ti5ZEPqpXMV3ibRQcS3G9Q.png" /><figcaption>Metamask import account</figcaption></figure><p>Nos va a presentar la opción de importar una cuenta por clave privada:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*2Aao8HeQ1cTiWZhbZmZGeQ.png" /></figure><p>Utilizamos la clave privada de una de nuestras cuentas de prueba.</p><p>Ahora vamos a añadir la red de prueba de Hardhat, nos es muy diferente a la red localhost existente en Metamask, pero por fines de aprendizaje agregaremos una nueva.</p><p>Vamos de nuevo a Metamask, hacemos click en el Blockie y luego damos click Settings, en settings vamos a Networks, ahi podemos hacer click en Add Network, en el formulario agregamos la información siguiente:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*snOq8nOcM4VdxI-9eBW4_w.png" /><figcaption>Agregando Hardhat Network</figcaption></figure><p>Con esto ya podemos cambiar la Network en Metamask a Hardhat, de esta manera:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*u1epjjhTjB6rJOOLChlSvw.png" /><figcaption>Hardhat network seleccionada</figcaption></figure><p>Y ahora podemos conectarnos a nuestra app frontend, que se esta ejecutando en:</p><p><a href="http://localhost:3000/">http://localhost:3000</a></p><p>Por ultimo agregaremos la habilidad de comprar un Token desde nuestra frontend, para ello debemos ir a la carpeta components dentro de frontend/pages agregaremos un archivo abi.json en esta carpeta y le agregaremos la siguiente información.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b6f83f0b7f0fcca2a9cfe7827c1c5c1/href">https://medium.com/media/5b6f83f0b7f0fcca2a9cfe7827c1c5c1/href</a></iframe><p>aquí modificaremos el archivo de panels.jsx y haremos los siguientes cambios:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbaebb464ae1a13761c9173264f47011/href">https://medium.com/media/dbaebb464ae1a13761c9173264f47011/href</a></iframe><p>Con estos cambios podemos comprar un token desde nuestra aplicación:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mrp5bO-dD6R04wYoW1VfpA.png" /><figcaption>Frontend conectado a nuestro contracto</figcaption></figure><p>Con esto culminamos este pequeño tutorial donde creamos una dapp, probamos nuestros contratos y conectamos el contrato a nuestro frontend.</p><p>Déjame saber en los comentarios que te pareció y si te gustaría ver más contenido de este tipo.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61e98d40993a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to add DAO governance to existing token contracts]]></title>
            <link>https://medium.com/tally-blog/how-to-add-dao-governance-to-existing-token-contracts-397855f081ac?source=rss-9f2385c5ee63------2</link>
            <guid isPermaLink="false">https://medium.com/p/397855f081ac</guid>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[dao]]></category>
            <category><![CDATA[token]]></category>
            <category><![CDATA[upgrade-smart-contract]]></category>
            <category><![CDATA[governance]]></category>
            <dc:creator><![CDATA[Natacha De la Rosa]]></dc:creator>
            <pubDate>Wed, 01 Jun 2022 14:45:10 GMT</pubDate>
            <atom:updated>2026-01-16T20:42:54.354Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W-jdJ9VtspuDOW6b7LnEhw.png" /></figure><p>In my <a href="https://blog.tally.xyz/how-to-create-an-nft-dao-47669a9e4e3a">previous post</a>, I talked about how to make your NFT contract DAO-ready from day one. But what if you have already deployed your NFT or ERC20 token contract without a future DAO? How can you add DAO governance using that existing token? Let&#39;s find out.</p><p>You can turn your token contract into a DAO by adding a <a href="https://docs.openzeppelin.com/contracts/4.x/api/governance">Governor Contract</a> to manage proposals and votes for your DAO. But before you can do that, you&#39;ll need to make sure your token contract is compatible with the governor.</p><p>The governor expects a particular <a href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/governance/utils/IVotes.sol">interface</a> from the token contract. Here&#39;s a summary of what it needs:</p><ul><li>Your token contract needs a <strong>delegate()</strong>, <strong>delegateBySig()</strong>, and <strong>delegates()</strong> functions<strong> </strong>to delegate votes from one user to another.</li><li>Your token contract needs to have a clear definition of how to calculate the voting power of each token holder. Usually, one token = one vote, but you can also customize a formula based on the token supply. It needs to have these function definitions <strong>getVotes()</strong>, <strong>getPastVotes() </strong>and <strong>getPastTotalSupply().</strong></li><li>Last but not least, your token contract needs to emit event logs for vote changes, token transfers, and delegation changes. It needs to have these specific events definitions <strong>DelegateChanged</strong>, <strong>DelegateVotesChanged</strong>, and <strong>Transfer</strong>.</li></ul><p>To get more information about what these functions and events signatures look like and what they should return, please read the <a href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/governance/utils/IVotes.sol">Open Zeppelin IVotes definition</a>.</p><p>Now that you know what your token contract needs, I can explain how you can achieve this. There are two ways, depending on how you created your token contract in the first place.</p><p>With the <a href="https://docs.openzeppelin.com/contracts/4.x/">OpenZeppelin</a> contracts library, I can add <strong>ERC20Votes</strong> or <strong>ERC721Votes</strong> accordingly depending on my token type and override some necessary methods even if my contract is not upgradable.</p><p><a href="#03f6">If your contract is </a><a href="#40e9">upgradable</a>, you&#39;ll need to create a new implementation and update the proxy so it implements the additional libraries your token contract needs.</p><p><a href="#40e9">If your contract is not upgradable</a>, you&#39;ll create an additional contract with the features I&#39;ve mentioned above. Then you&#39;ll need to allow users to <strong>stake</strong> the tokens they hold to mint the new ones.</p><h3>1. Your token contract is upgradable</h3><p>If this is your case, you have the easiest path forward.</p><p>You need to have administration permissions of the contract to perform these changes. If you don&#39;t, you won&#39;t be able to update the token implementation of the upgradable contract.</p><p>First, let&#39;s say I have the following token contract that I&#39;ve deployed on Rinkeby. It doesn&#39;t support delegation or any other voting capabilities, but it is upgradable:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62a66c5dd086cc383de2ed3f95553014/href">https://medium.com/media/62a66c5dd086cc383de2ed3f95553014/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df5b8c4d23e126ee52b2d98e50222e72/href">https://medium.com/media/df5b8c4d23e126ee52b2d98e50222e72/href</a></iframe><p>Now, I need to update my token to have a new implementation that supports delegation and other voting capabilities like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2122f8755de4613987dd7c7f3326679a/href">https://medium.com/media/2122f8755de4613987dd7c7f3326679a/href</a></iframe><p>After that, I can run the update task, and my contract will have the new implementation I need:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/21e34f2e91a67281b9aab4d1c7362d94/href">https://medium.com/media/21e34f2e91a67281b9aab4d1c7362d94/href</a></iframe><p>That&#39;s it, and now my token contract has everything it needs to be used with my governor contract!</p><h3>2. Your token contract is not upgradable</h3><p>If this is your case, don&#39;t worry. Everything has a solution. You&#39;ll need a few more steps but nothing too complicated.</p><p>I&#39;ll first create a new contract; you can make it upgradable or not, but in this example, I&#39;ll make it not upgradable to show both sides. If you want to create it to be upgradable, you can refer to the previous one I created.</p><p>I will implement the features I need to make my token compatible with a governor contract in this new token contract. Then I&#39;ll create two additional functions to allow my token users to <strong>stake</strong> their tokens and <strong>withdraw</strong> them from this contract.</p><p>You will also need to create a simple UI to allow your users to do these actions. That&#39;s all you&#39;ll need to do. Let&#39;s jump right into it.</p><p>Let&#39;s say I have this ERC721 token that is already deployed in Rinkeby, but it doesn&#39;t have any upgradable capabilities:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/49e771945013913c3515f1660cda7210/href">https://medium.com/media/49e771945013913c3515f1660cda7210/href</a></iframe><p>In this case, I&#39;ll need to create a new ERC721 token that has the DAO capabilities I need. This new contract will allow current token holders to deposit their owned tokens. Then, they can receive the new voting token and participate in my DAO. The token holders will also have the option to withdraw their staked tokens.</p><p>Let&#39;s start by creating the new ERC721 token like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b34877ef88a61bccc9bf769f8d43c176/href">https://medium.com/media/b34877ef88a61bccc9bf769f8d43c176/href</a></iframe><p>My new ERC721 token contract should have these functionalities:</p><ul><li><strong>Mintable</strong>: I&#39;ll use this functionality to mint a unique token for my token holders each time they <strong>stake</strong> a token they hold of <strong>OldNFTToken</strong> into the <strong>NewNFTToken</strong>.</li><li><strong>Burnable: </strong>I&#39;ll use this functionality to burn a minted <strong>NewNFTToken </strong>when the holder withdraws <strong>NewNFTToken</strong>.</li></ul><p>Now I&#39;ll add two new functions to my new contract to manage the <strong>staking</strong> and <strong>withdrawing</strong> processes:</p><ol><li>First, create a state variable to receive the current NFT contract address.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d59cccf8bdd57c91f10ae69f54161456/href">https://medium.com/media/d59cccf8bdd57c91f10ae69f54161456/href</a></iframe><p>2. Now, I&#39;ll update the constructor to receive the address of my <strong>OldNFTToken.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/371340ff32ea84b0f6a149c311107afa/href">https://medium.com/media/371340ff32ea84b0f6a149c311107afa/href</a></iframe><p>3. I&#39;ll also update the <strong>safeMint</strong> function to look like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2bb98a36f3cff770b0665e113114626/href">https://medium.com/media/b2bb98a36f3cff770b0665e113114626/href</a></iframe><p>4. Then, I&#39;ll add the functions to <strong>stake </strong>and <strong>withdraw</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/abfaa7d37dedde4c12aa572487a77d6b/href">https://medium.com/media/abfaa7d37dedde4c12aa572487a77d6b/href</a></iframe><p>5. Last but not least, I&#39;ll add <strong>ERC721Receiver</strong> implementation to my contract so that it can support safe transfers:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4dfc6183e859e98f7667b77558442628/href">https://medium.com/media/4dfc6183e859e98f7667b77558442628/href</a></iframe><p>Now the new ERC721 token should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/75ed93894e012ae9c76b8f5f340944c0/href">https://medium.com/media/75ed93894e012ae9c76b8f5f340944c0/href</a></iframe><p>That&#39;s it. Now you can use the <strong>NewNFTToken</strong> in your governor.</p><h3>3. Adding a Governor</h3><p>Now that we have seen how to update both types of tokens to support voting and delegation so they work with the governor contract, I&#39;ll create the contracts I need to deploy my governor. First, I&#39;ll create a Timelock contract:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/671a0bac92a02533b2b36fcf9015f2f5/href">https://medium.com/media/671a0bac92a02533b2b36fcf9015f2f5/href</a></iframe><p>2. Now, I&#39;ll create my governor contract. It should look like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b59e376433d7eb17419b2d8009880a7f/href">https://medium.com/media/b59e376433d7eb17419b2d8009880a7f/href</a></iframe><p>We can now <strong>compile</strong> and <strong>generate</strong> the typings of our contracts:</p><pre>yarn compile &amp; yarn typechain</pre><p>3. Finally, I&#39;ll create a hardhat task to deploy our contracts. It should look like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8d7501126a36531e42f60c2f04c3651/href">https://medium.com/media/b8d7501126a36531e42f60c2f04c3651/href</a></iframe><p>Now to deploy our new governor, we can run:</p><pre>yarn hardhat deploy:Governance</pre><p>We have completed this small tutorial, and we&#39;ve learned how to update our token contract to be DAO-ready and deploy a governor contract for them. You can create a DAO and <a href="https://www.tally.xyz/register/protocol">list it on Tally</a> with your new governor and token.</p><p>You can find the sample code for this tutorial <a href="https://github.com/withtally/add-governance-to-existing-tokens">here</a>.</p><p>I hope you enjoyed this post. Feel free to post in the comments with your thoughts, questions, and any requests for future posts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=397855f081ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tally-blog/how-to-add-dao-governance-to-existing-token-contracts-397855f081ac">How to add DAO governance to existing token contracts</a> was originally published in <a href="https://medium.com/tally-blog">Tally</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create an NFT DAO]]></title>
            <link>https://medium.com/tally-blog/how-to-create-an-nft-dao-47669a9e4e3a?source=rss-9f2385c5ee63------2</link>
            <guid isPermaLink="false">https://medium.com/p/47669a9e4e3a</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[dao]]></category>
            <category><![CDATA[nft]]></category>
            <dc:creator><![CDATA[Natacha De la Rosa]]></dc:creator>
            <pubDate>Mon, 18 Oct 2021 17:13:38 GMT</pubDate>
            <atom:updated>2026-01-16T21:09:20.940Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W-jdJ9VtspuDOW6b7LnEhw.png" /></figure><p>Are you looking to build at the intersection of DAOs and NFTs? You&#39;re in the right place.</p><p>This post aims to help you create a DAO-ready NFT project from day 1. We&#39;ll walk through the steps to create an on-chain DAO where 1 NFT = 1 vote. You&#39;ll need a working knowledge of the Solidity build environment.</p><p>We&#39;ll use the <a href="https://github.com/paulrberg/solidity-template"><strong>PaulrBeerg Solidity Template</strong></a>, which has all the configuration needed to start writing our contracts.</p><p>We&#39;ll also mix in a few Solidity libraries:</p><ul><li><strong>Open Zeppelin ERC721:</strong> a token contract that implements the Non-Fungible Token standard.</li><li><strong>Open Zeppelin Governor</strong>: contract for creating and voting on DAO proposals.</li><li><strong>Open Zeppelin ERC721Votes:</strong> This contract implements the support for voting and delegation, where each individual NFT counts as one vote unit.</li><li><a href="https://github.com/withtally/my-nft-dao-project/blob/main/contracts/Timelock.sol"><strong>Timelock</strong></a><strong>:</strong> This contract will allow the successful proposals to enter a review period before execution.</li></ul><h3>Let&#39;s dive in!</h3><ol><li>First, let&#39;s create our repository using <a href="https://github.com/paulrberg/solidity-template">Paul&#39;s solidity template</a>. You can use this command:</li></ol><pre>git clone <a href="https://github.com/paulrberg/solidity-template.git">https://github.com/paulrberg/solidity-template.git</a> my-nft-dao-project</pre><p>2. After creating our repository, we can go to the created directory:</p><pre>cd my-nft-dao-project</pre><p>3. In the project directory, let&#39;s run the `yarn` installation command:</p><pre>yarn install</pre><p>4. Now, we can open the project in our favorite editor, and it should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*e16NtWO_Igy9qbvzxh9K3Q.png" /><figcaption>Project structure</figcaption></figure><p>We won&#39;t jump into the details of the project structure. Instead, we&#39;ll focus on the following folders:</p><ul><li><strong>contracts/</strong>folder, which is where all our <strong>solidity</strong> contracts will be. You can add more subfolders if you want a more detailed structure. We won&#39;t do so in this tutorial.</li><li><strong>tasks/</strong>folder, which is where we&#39;ll add the scripts needed to deploy our contracts in our desired Ethereum network.</li></ul><p>5. We&#39;ll need to add a <strong>.env</strong> file following the <strong>.env.template</strong> defined in the project folder. These variables are necessary for deploying our contract later and are used in the <strong>hardhat.config.ts</strong> file in our root folder:</p><pre># Any RPC endpoint goes here. Doesn&#39;t have to be Infura<br>INFURA_API_KEY=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz</pre><pre># This is the MNEMONIC of a rinkeby account<br>MNEMONIC=here is where your twelve words mnemonic should be put my friend</pre><p>6. Now, let&#39;s add the OpenZeppelin contracts library package to our project:</p><pre>yarn add @openzeppelin/contracts</pre><h3>Let&#39;s start coding</h3><p>First, let&#39;s add our NFT contract. We&#39;ll keep it to the minimum for this tutorial:</p><ol><li>Let&#39;s add a file called <strong>MyNftToken.sol</strong> in our contracts folder</li><li>Now let&#39;s add the following code to our file:</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d180994f2e6de5e85d83ab8e3a1fe6c/href">https://medium.com/media/6d180994f2e6de5e85d83ab8e3a1fe6c/href</a></iframe><p>This simple NFT contract implementation allows minting new tokens using the <strong>safeMint</strong> function and keeps track of the issued token count using the <strong>_tokenIdCounter</strong>.</p><p>Also, we import <strong>ERC721Votes </strong>to make our token contract compatible with the DAO Governor contract we&#39;ll implement later. This helps keep track of how many votes a token holder has along with other important information, such as whether they have delegated their voting power to another account, etc.</p><p>Now, let&#39;s add our Governor contract. You can either use the <a href="https://wizard.openzeppelin.com/#governor">OpenZeppelin Contract Wizard</a> or create it step by step:</p><ol><li>Let&#39;s make a fileInalled <strong>MyGovernor.sol</strong> in our contracts folder:</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6fc979ec40889bc347abe8c9f468439/href">https://medium.com/media/c6fc979ec40889bc347abe8c9f468439/href</a></iframe><p>Now, let&#39;s review this file to understand what we&#39;re doing with it:</p><ol><li>We&#39;ll import OpenZeppelin contracts instances of Governor, GovernorVotes, GovernorSettings, and GovernorCountingSimple to create the the base of MyGovernor contract.</li><li>We also import GovernorTimelockCompound to make our governor contract compatible with Compound style Timelock.</li><li>Then, in the constructor for our Governor contract, we&#39;ll initialize the governor contract with a name and tell the addresses we will use for the token contract and the timelock contract.</li><li>After calling the constructor, we&#39;ll define the configuration of our governor contract. Generally, these rules trade-off between making proposals easier and harder to pass. Your DAO can change them later, but only with an on-chain vote.</li></ol><ul><li><a href="https://docs.openzeppelin.com/contracts/4.x/api/governance#Governor-votingDelay-">votingDelay</a>: the number of blocks a proposal needs to wait after creation to become active and allow voting. Usually set to zero, a longer delay gives people time to set up their votes before voting begins.</li><li><a href="https://docs.openzeppelin.com/contracts/4.x/api/governance#Governor-votingPeriod-">votingPeriod</a>: number of blocks to run the voting. A more extended period gives people more time to vote. Usually, DAOs set the period to somewhere between 3 and 6 days.</li><li><a href="https://docs.openzeppelin.com/contracts/4.x/api/governance#Governor-quorum-uint256-">quorum</a>: the minimum number of &#39;Yes&#39; votes needed for the proposal to pass. Usually, DAOs are set to 1–2% of the outstanding tokens, but a token with a wide distribution and few whales might want to put it lower.</li><li><a href="https://docs.openzeppelin.com/contracts/4.x/api/governance#GovernorProposalThreshold">proposalThreshold</a>: the minimum amount of voting power an address needs to create a proposal. A low threshold allows spam, but a high threshold makes proposals nearly impossible! DAOs are set to a number that will enable 5 or 10 of the largest token holders to create proposals.</li></ul><p>4. Last, we&#39;ll add overrides for the following functions. These interfaces are abstract, so we need to implement these functions:</p><ul><li><strong>getVotes</strong> — Gets the number of votes a user had before the proposal goes live</li><li><strong>state</strong> — Gets the current state of the specified proposal</li><li><strong>propose</strong> — Creates a proposal if the sender has enough votes</li><li><strong>_execute</strong> — Sends the proposal for execution. The proposal must have surpassed the required timelock delay</li><li><strong>_cancel</strong> — Cancels the specified proposal if its creator falls below the required threshold</li><li><strong>_executor</strong> — Gets the address through which the Governor executes an action. In our case, the timelock address.</li><li><strong>supportsInterface</strong> — ERC165 that allows validating the interfaces used in our contract</li></ul><p>Now, let&#39;s add our Timelock contract:</p><pre>cd contracts/<br>curl https://raw.githubusercontent.com/withtally/my-nft-dao-project/main/contracts/Timelock.sol --output Timelock.sol</pre><p>Now our contracts folder should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*gwrN1Wds-dQ-R9OQCeIGbw.png" /><figcaption>contracts folder</figcaption></figure><p>If you&#39;re missing something, compare your project to this <a href="https://github.com/withtally/my-nft-dao-project">example repository</a>.</p><p>Next, we&#39;ll make sure the contracts compile:</p><pre>yarn compile</pre><h3>Let&#39;s deploy</h3><ol><li>First, we&#39;ll add this <strong>getExpectedContractAddress</strong> function so that our deploy script can tell the <strong>Timelock</strong> where to find the <strong>Governor</strong>. We&#39;ll add a <strong>utils.ts</strong> file in our project <strong>tasks/</strong> folder and add the code below:</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a354635d9f05b1a4817d016f1967d8f/href">https://medium.com/media/8a354635d9f05b1a4817d016f1967d8f/href</a></iframe><p>2. We&#39;ll create a new <a href="https://hardhat.org/guides/create-task.html">hardhat task</a>. These tasks help automate steps in our contract development process. Let&#39;s add a new file in the <strong>tasks/deploy/</strong> folder in our project and name it <strong>dao.ts,</strong> and add the following to it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/afefa20a6980fd058b82748843d8c4c5/href">https://medium.com/media/afefa20a6980fd058b82748843d8c4c5/href</a></iframe><p>3. We&#39;ll add the DAO task to the <strong>tasks/index.ts</strong> file:</p><pre>import &quot;./dao&quot;;</pre><p>4. Let&#39;s update our <strong>package.json</strong> deploy script line to look like this:</p><pre>&quot;scripts&quot;: {<br>	...<br>	&quot;deploy&quot;: &quot;hardhat deploy:Dao&quot;,<br>}</pre><p>It&#39;s always essential to verify our smart contracts code on Etherscan. That way, our users can validate that the deployed contract does what it claims to do.</p><p>4. Now, let&#39;s add the library needed to verify our contracts on Etherscan:</p><pre>yarn add -D @nomiclabs/hardhat-etherscan</pre><p>5. In our root folder, let&#39;s find the <strong>hardhat.config.ts</strong> and update the configuration object to include the Etherscan config:</p><pre>import &quot;@nomiclabs/hardhat-etherscan&quot;; // add the import of the plugin</pre><pre>const config: HardhatUserConfig = {<br>	...<br>	etherscan:{ apiKey: process.env.ETH_SCAN_API_KEY },<br>}</pre><p>6. Next, we&#39;ll add the API key as an environment variable to our <strong>.env</strong> file. You can get your Etherscan API key <a href="https://etherscan.io/apis">here</a>:</p><pre>ETH_SCAN_API_KEY=</pre><p>7. Now, we can deploy our contracts in R<strong>inkeby</strong> using the following command. Make sure the account which <strong>mnemonic</strong> we set up on the <strong>.env</strong> has testnet <strong>Rinkeby ether </strong>for gas!</p><pre>yarn deploy --network rinkeby</pre><p>8. Add your DAO to <a href="http://tally.xyz/">Tally</a> using <a href="https://www.tally.xyz/register/protocol">this form</a>. This will make it easy for your community to create proposals, vote, and delegate.</p><p>All right! You did it!</p><p>We now have an NFT DAO deployed and verified on Etherscan. Our budding NFT community can vote on implementing the NFT contract and how to spend any money in the treasury.</p><p>Please comment with any questions, suggestions, or success stories!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47669a9e4e3a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tally-blog/how-to-create-an-nft-dao-47669a9e4e3a">How to create an NFT DAO</a> was originally published in <a href="https://medium.com/tally-blog">Tally</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>