<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kevin Bravo</title>
    <description>The latest articles on DEV Community by Kevin Bravo (@bravok).</description>
    <link>https://dev.to/bravok</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F812028%2Ff41c3b57-da2e-42f6-adb6-5f0f1a666003.jpeg</url>
      <title>DEV Community: Kevin Bravo</title>
      <link>https://dev.to/bravok</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bravok"/>
    <language>en</language>
    <item>
      <title>How to create a table of content for a Dev.to post</title>
      <dc:creator>Kevin Bravo</dc:creator>
      <pubDate>Wed, 02 Mar 2022 07:05:19 +0000</pubDate>
      <link>https://dev.to/bravok/how-to-create-a-table-of-content-for-your-devto-post-1e2f</link>
      <guid>https://dev.to/bravok/how-to-create-a-table-of-content-for-your-devto-post-1e2f</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;p&gt; 1. Basic about markdowns&lt;br&gt;
       1.1. Headers&lt;br&gt;
       1.2. Links&lt;/p&gt;

&lt;p&gt; 2. Basic Table of content (manually)&lt;br&gt;
 4. Create your Table of content automatically.&lt;/p&gt;



&lt;p&gt;In this article I'm going to show you how you can &lt;strong&gt;create a table of content (ToC) for your dev.to post automatically.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is based on this previous post of &lt;a class="mentioned-user" href="https://dev.to/goldenxp"&gt;@goldenxp&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'm going to explain a little bit how markdowns work, if you already know that and only want the code to make your ToC go to this section.&lt;/p&gt;
&lt;h2&gt;
  
  
  Basic about markdowns
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Headers
&lt;/h3&gt;

&lt;p&gt;So, when you want to write headers in markdown, you have to do something like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## my H2 header
### my H3 header
#### my H4 header
##### my H5 header
###### my H6 header
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And it looks something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foi1ues4hk2n83177r4gd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foi1ues4hk2n83177r4gd.png" alt="Screenshot from the dev.to preview format and the console"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Screenshot from the dev.to preview format and the console with the div object in which all the elements of an article are contained.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: you can have another H1 header, but it‘s not recommended, you must only have one H1 header for the title, this helps the semantics of the site, so You should use only from  H2 to H6  headers in the content of your article.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Links
&lt;/h3&gt;

&lt;p&gt;Links in markdown format looks like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[The hypertext](https//:mylink.com)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You must use the syntax &lt;code&gt;[]()&lt;/code&gt; to indicate that this element is a link. &lt;/p&gt;

&lt;p&gt;In your render document you will have something like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/KevBto" rel="noopener noreferrer"&gt;Link to my twitter account&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, those links are links would get you to another page, so if we want to write links that points to a specific position in our text, like in this github example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa7a4fqh2b5ei1f03nx4k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa7a4fqh2b5ei1f03nx4k.png" alt="Screnshot of a url example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The url from above:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://github.com/mustafinho/mustafinho/blob/main/AMA.md#octocat-computer-talk-techy-to-me&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It points to the same page but to a different point in the article,&lt;/strong&gt; and you can identify that by locating the “#” symbol after the original url of the page where you are.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Table of content (manually)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;We can make our ToC by using the different ‘H’ tags (H2,H3,H4,...)  and using the “#” so, we can redirect the user to a subsection of the article.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Opening the &lt;code&gt;console&lt;/code&gt; in the &lt;code&gt;preview&lt;/code&gt; mode of the dev.to text editor&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4e3tmrvguqqziq6c2t5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4e3tmrvguqqziq6c2t5.png" alt="image of the container in dev.to"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We can see how the links look within the article.&lt;/em&gt; &lt;strong&gt;In the &lt;code&gt;href&lt;/code&gt; section notice how the links are written.: “#” followed by the name of the section with the hyphens&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So, &lt;strong&gt;we can point to those headers and travel through the article directly to them&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We just need have to write:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;[click here to be redirected to my h4 section](#my-h4-header)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And you will get:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm8xrw3h74x7sgye5b5oq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm8xrw3h74x7sgye5b5oq.png" alt="Screnshot of the rendered markdown"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Notice the redirection link below&lt;/p&gt;

&lt;p&gt;So, for make our table of content, we can simply do something like this&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;to my h2 header&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;   a. to my h3 header&lt;/p&gt;

&lt;p&gt;     -  to my h4 header&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4nhoge4gc9e1zfkmrlsl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4nhoge4gc9e1zfkmrlsl.png" alt="screnshot of the rendered markdown"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;And that's it, we have our table of content.&lt;/p&gt;

&lt;p&gt;BUT, if you have a really big document, this could be kind of annoying doing all the h2,h3…. Tags that may have, so &lt;strong&gt;there has to be a way in which we can do this automatically right?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8i2tdjmx5y6wbzzrzc6d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8i2tdjmx5y6wbzzrzc6d.png" alt="Meme"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Right?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74vy9zzk7br7ds3p21fk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74vy9zzk7br7ds3p21fk.png" alt="Meme"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Yes, &lt;strong&gt;but it is not an official solution,&lt;/strong&gt; &lt;em&gt;I just write a javascript code that can be executed in the console that makes it automatically for you.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create your Table of content automatically.
&lt;/h2&gt;

&lt;p&gt;I just grab all the children tags that the container of the article has, and make a script so, if they are header tags, it will format and indent them, putting a number or a letter depending on the tag.&lt;/p&gt;

&lt;p&gt;We can see that the div in where all the content for the article is contained &lt;em&gt;(preview mode in the dev.to text editor with the console open)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffueorm14jzithtjvcs2p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffueorm14jzithtjvcs2p.png" alt="Screnshot of the container text"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Console in the text editor using the preview mode&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That's what this javascript code does.  👇&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;elements&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementsByClassName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;crayons-article__body text-styles&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;outputMarkDown&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;## Table of Contents&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;orderedNumbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;markDownIndentation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;actualIndex&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;actualSubIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;actualLetterIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;letters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;b&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;d&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;f&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;g&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;f&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;i&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;usedLetters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;elements&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nodeName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tag&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;H2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
    &lt;span class="nx"&gt;tag&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;H3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
    &lt;span class="nx"&gt;tag&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;H4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
    &lt;span class="nx"&gt;tag&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;H5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
    &lt;span class="nx"&gt;tag&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;H6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;link&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;firstElementChild&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;indent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tag&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;H2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;outputMarkDown&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;markDownIndentation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;indent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;outputMarkDown&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;markDownIndentation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;indent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;switch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;H2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;orderedNumbers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;indent&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="nx"&gt;actualIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;orderedNumbers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;indent&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="nx"&gt;actualIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;orderedNumbers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;indent&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
        &lt;span class="nx"&gt;outputMarkDown&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;nbsp;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;actualIndex&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;. &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;H3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;actualSubIndex&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;actualSubIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;actualSubIndex&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
        &lt;span class="nx"&gt;outputMarkDown&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;` &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;actualIndex&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;actualSubIndex&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. `&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;H4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nx"&gt;usedLetters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;letters&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;actualLetterIndex&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="nx"&gt;letters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;actualLetterIndex&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nx"&gt;outputMarkDown&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;` &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;usedLetters&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;actualLetterIndex&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="s2"&gt;. `&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;actualLetterIndex&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;H5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nx"&gt;outputMarkDown&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;- &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tag&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;H6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;outputMarkDown&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;[*&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;*](&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;link&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;outputMarkDown&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;](&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;link&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;outputMarkDown&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You just need to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Have an amazing article with subsections (H2,H3,H4..)&lt;/li&gt;
&lt;li&gt;Copy the above code&lt;/li&gt;
&lt;li&gt;Go to the text editor of dev.to&lt;/li&gt;
&lt;li&gt;Click in the  preview mode 
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4zberozxsov616sxsj5j.png" alt="Screnshot of the dev.to editor in preview mode"&gt; &lt;/li&gt;
&lt;li&gt;Open the console&lt;/li&gt;
&lt;li&gt;Paste the code in the console.&lt;/li&gt;
&lt;li&gt;Press enter&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ta da!, you have your table of content completely formatted for your amazing dev.to post.&lt;/p&gt;

&lt;p&gt;Now, you just have to copy that output and paste it in your text.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I'm not going to explain in dev what this javascript code does, because is out of the purposes of this article, but I will explained in the &lt;a href="https://github.com/mustafinho/devto-table-content-creator" rel="noopener noreferrer"&gt;github repo of the script&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Again, thanks to &lt;a href="https://dev.to/goldenxp/adding-table-of-contents-to-dev-to-posts-1ba4"&gt;this post&lt;/a&gt; for the inspiration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DISCLAIMER:&lt;/strong&gt; take into account that the configuration for the script may change with the time as the team of dev to change the layout of it's page.&lt;/p&gt;




&lt;p&gt;That's all folks.&lt;/p&gt;

&lt;p&gt;I hope this article was helpful for you.&lt;/p&gt;

&lt;p&gt;If you have any comment or suggestions, please leave it in the comments section.&lt;/p&gt;

&lt;p&gt;You can follow me on twitter &lt;a href="https://twitter.com/_bravok" rel="noopener noreferrer"&gt;@_bravok&lt;/a&gt; and DM me, I’m always happy to talk and get to know more people in this amazing community.&lt;/p&gt;

&lt;p&gt;If you publish your article and use this method to generate your table of content, share your article on twitter and tag me (@kevbto). Let me see your incredible creation, I'll retweet&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>javascript</category>
      <category>bloging</category>
    </item>
    <item>
      <title>Brownie: everything you need to know to write, test and deploy your smart contracts.</title>
      <dc:creator>Kevin Bravo</dc:creator>
      <pubDate>Tue, 22 Feb 2022 02:18:30 +0000</pubDate>
      <link>https://dev.to/bravok/brownie-everything-you-need-to-know-to-write-test-and-deploy-your-smart-contracts-2lfl</link>
      <guid>https://dev.to/bravok/brownie-everything-you-need-to-know-to-write-test-and-deploy-your-smart-contracts-2lfl</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;p&gt; 1. How to install brownie&lt;br&gt;
 2. Brownie basics&lt;br&gt;
 3. The brownie config file&lt;/p&gt;

&lt;p&gt;       3.1. Remapping import paths.&lt;br&gt;
             a. Adding the dependencies section.&lt;/p&gt;

&lt;p&gt;       3.2. Adding new sections to grab information from.&lt;br&gt;
             b. Adding a simple section&lt;br&gt;
             c. Adding a section to grab information conditionally.&lt;/p&gt;

&lt;p&gt; 4. Using environment variables&lt;br&gt;
 5. Working with networks&lt;br&gt;
       5.3. Network elements&lt;br&gt;
       5.4. Adding forked network.&lt;br&gt;
       5.5. Deleting an existing network.&lt;br&gt;
       5.6. Updating an existing network.&lt;/p&gt;

&lt;p&gt; 6. Working with accounts.&lt;br&gt;
 7. Function entry point.&lt;br&gt;
 8. Verify your contracts on etherscan&lt;br&gt;
       8.7. Verifying contracts on other blockchains.&lt;/p&gt;

&lt;p&gt; 9. Sources.&lt;/p&gt;



&lt;p&gt;Actually, brownie is one of the most popular frameworks to create smart contracts, alongside truffle and hardhat.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Brownie offers a lot of cool things and functionalities you can use to make your development process more simple.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So, whether you're starting your journey as a blockchain developer, or you already have experience with smart contract development in Javascript but you want to shift to python, this tutorial is for you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We’ll walk through and explore all the main areas of functionality and I'll give you some tricks you can use to make your development process more easy.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's start!&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How to install brownie
&lt;/h2&gt;

&lt;p&gt;There are two easy ways in which you can install brownie:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. By using pipx&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pipx&lt;/code&gt; is just a like &lt;code&gt;pip&lt;/code&gt;, but you can install those packages and run it directly in the command line&lt;/p&gt;

&lt;p&gt;Is focused on installing and managing Python packages that can be run from the command line directly as applications.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Whereas &lt;code&gt;pip&lt;/code&gt; is a general-purpose package installer for both libraries and apps with no environment isolation. &lt;code&gt;pipx&lt;/code&gt; &lt;strong&gt;is made specifically for application installation, as it adds isolation yet still makes the apps available in your shell:&lt;/strong&gt; &lt;code&gt;pipx&lt;/code&gt; creates an isolated environment for each application and its associated packages.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;From the &lt;a href="https://github.com/pypa/pipx#how-is-it-different-from-pip" rel="noopener noreferrer"&gt;pipx documentation.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That means, you don't have to create a python virtual environment when a package needed it.&lt;/p&gt;

&lt;p&gt;I recommend using this method, if so,you just can follow along the tutorial in the brownie documentation &lt;a href="https://eth-brownie.readthedocs.io/en/stable/install.html#installing-brownie" rel="noopener noreferrer"&gt;here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Using the common python pip&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To be able to install brownie without &lt;code&gt;pipx&lt;/code&gt;, you first need to create a virtual environment.&lt;/p&gt;

&lt;p&gt;A virtual environment in python is a contained environment for separate projects on your computer 🐍. What this means is that &lt;strong&gt;you can have separate virtual environments with separate versions of python and python packages for each of your projects.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can create one just by typing:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ python3 -m venv &amp;lt;path + name of your virtual environment&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python -m venv ./myVirtualEnviroment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;After the creation process is done, you will need to activate the virtual environment:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ source myVirtualEnviroment/bin/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Or&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ source  myVirtualEnviroment/Scripts/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;And then, you just need to write:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pip install eth-brownie
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;With that you'll be able to use brownie.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Take into account that this only will work in the current directory, if you change from directory you will need to create and activate a virtual environment again. Also, if you close your current session of the command line and you want to work with the project again you will need to activate the virtual environment again.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To make sure that everything works fine, in both scenarios, write&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ brownie
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643839805789%2FTCsH9-fK8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643839805789%2FTCsH9-fK8.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you need more information about the instalation process of brownie, you can follow &lt;a href="https://iamdefinitelyahuman.medium.com/getting-started-with-brownie-part-1-9b2181f4cb99" rel="noopener noreferrer"&gt;this tutorial&lt;/a&gt; made** by Ben Hauser on Medium**&lt;/p&gt;

&lt;p&gt;Also, you can follow the &lt;a href="https://eth-brownie.readthedocs.io/en/stable/install.html" rel="noopener noreferrer"&gt;brownie documentation&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Brownie basics
&lt;/h2&gt;

&lt;p&gt;I'm not going to dive deep into the basics of brownie, for that the brownie team wrote an excellent documentation that you can check &lt;a href="https://eth-brownie.readthedocs.io/en/stable/quickstart.html" rel="noopener noreferrer"&gt;here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, you can read these greats tutorial made by Ben Hauser, &lt;a href="https://betterprogramming.pub/getting-started-with-brownie-part-2-615a1eec167f" rel="noopener noreferrer"&gt;tutorial one&lt;/a&gt;, &lt;a href="https://betterprogramming.pub/getting-started-with-brownie-part-3-ef6bfa9867d7" rel="noopener noreferrer"&gt;tutorial two.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I'm just going to make you a resume:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Initialized templates for projects, so you don't have to start from scratch.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;$ brownie bake &amp;lt;name of the template&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compile your contracts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;$ brownie compile&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write test for your contracts. Writing the test in the &lt;code&gt;test&lt;/code&gt; folder and typing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;$ brownie test&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can also interact with the contract using scripts or via the brownie console.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the &lt;code&gt;scripts&lt;/code&gt; folder you can write your scripts to interact with the contract programmatically, and then you write:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ brownie run scripts&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Or, using the console you can interact with the contract manually.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ brownie console&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deploy your contracts in a controlled environment (using ganache under the hood)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;$ brownie deploy&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;And also deploy to a testnet or a real net&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;$ brownie deploy --network &amp;lt;name of the network&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You also can do this when you are testing your contracts.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ brownie test --network &amp;lt;name of the network&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Or runing your scripts&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ brownie run scripts --network &amp;lt;name of the network&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The brownie config file
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;This is a special file that brownie always looks for to grab information when you are going to build, test and deploy your contract…&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This file &lt;strong&gt;allows you to modify Brownie’s default behaviors and also add new sections&lt;/strong&gt; that can be useful for you when you are working in your smart contract.&lt;/p&gt;

&lt;p&gt;I'm not going to deep dive in all the sections that the file have, you could see those in the &lt;a href="https://eth-brownie.readthedocs.io/en/stable/config.html" rel="noopener noreferrer"&gt;brownie documentation.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I'm just going to explain some things that could be useful for you.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You need to add this file to the root of your project and name it &lt;code&gt;brownie-config.yaml&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;One of the things you can do is:&lt;/p&gt;
&lt;h3&gt;
  
  
  Remapping import paths.
&lt;/h3&gt;

&lt;p&gt;Let's say that your contract need to use some functionality from other contract, like a template or a library (the safe math library or the ERC721 standard template of &lt;a href="https://openzeppelin.com/" rel="noopener noreferrer"&gt;Open Zeppelin&lt;/a&gt; for example)&lt;/p&gt;

&lt;p&gt;You can do that without copying the contract interface to your project, &lt;strong&gt;you can just pull the source code from the npm package that hosts the code.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Example, let's said that you need to import the Open Zeppelin contract &lt;em&gt;Ownable&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;For this you'll need to install the open zeppelin npm package, &lt;strong&gt;but with remappings you don't need it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Just import the package as usual in your solidity file.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "@openzeppelin/contracts/ownership/Ownable.sol";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;And then, in your &lt;code&gt;brownie-config.yaml&lt;/code&gt; file, you can use one of it's default sections called &lt;code&gt;compiler&lt;/code&gt; to change it's behavior.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;In this section you add a subsection called &lt;code&gt;solc&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;And in this subsection you add another subsection called &lt;code&gt;remappings&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You should have something like this:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;compiler:
    solc:
        remappings:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Each value under remappings is a string in the format of &lt;code&gt;prefix=path&lt;/code&gt;&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;A remapping instructs the compiler to search for a given prefix at a specific path&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;github.com/ethereum/dapp-bin/=/usr/local/lib/dapp-bin/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;This remapping instructs the compiler to search for anything starting with &lt;code&gt;github.com/ethereum/dapp-bin/&lt;/code&gt; under &lt;code&gt;/usr/local/lib/dapp-bin&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Brownie automatically ensures that all remapped paths are allowed.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And now, if we want to use our Open Zeppelin ownable contract, &lt;strong&gt;we just need to follow that prefix=path format.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By having a prefix &lt;/p&gt;

&lt;p&gt;&lt;code&gt;@openzeppelin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And then, having the path that rute us to the open zeppelin package in NPM, that is usually stored on GitHub.&lt;/p&gt;

&lt;p&gt;We can obtain that searching by googling &lt;em&gt;open zeppelin ownable contract&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643847873973%2FvdLDGCg89.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643847873973%2FvdLDGCg89.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643849387151%2Fp_Qjfqc0-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643849387151%2Fp_Qjfqc0-.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And we can use this information to make the path, should be wrote in this format:&lt;br&gt;
    @&lt;/p&gt;

&lt;p&gt;First, we need to add the organization, that means the username who create the repo. In this case:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;OpenZeppelin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then we need to add the github repo in which is store the code. In this case&lt;/p&gt;

&lt;p&gt;&lt;code&gt;openzeppelin-contracts&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We would have something like this for the path&lt;/p&gt;

&lt;p&gt;&lt;code&gt;OpenZeppelin/openzeppelin-contracts&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And finally, we need to add the package version we want to work with.&lt;/p&gt;

&lt;p&gt;In the root of the repo we can see all the releases (the versions).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643849331423%2FAWpD6ZL9h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643849331423%2FAWpD6ZL9h.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By pressing in &lt;strong&gt;releases&lt;/strong&gt; you can see all the different versions you can use, &lt;em&gt;this is going to depend mostly of the specifications of the project you are working on,&lt;/em&gt; but you can really chose whatever you want.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643851974060%2FzeWT9xD5Yc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643851974060%2FzeWT9xD5Yc.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You need to add the version by adding an “@” at the beginning.&lt;/p&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Working with version 4.4.1:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;OpenZeppelin/openzeppelin-contracts@4.4.1&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Or version 4.3.1&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;OpenZeppelin/openzeppelin-contracts@4.3.1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That's it, now in your remappings section you should have something like this:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;compiler:
    solc:
        remappings:
            - '@openzeppelin=OpenZeppelin/openzeppelin-contracts@4.3.1'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Now, everytime the compiler see &lt;code&gt;@openzeppelin&lt;/code&gt; in your solidity code, will search that import under the &lt;code&gt;OpenZeppelin/openzeppelin-contracts@4.3.1&lt;/code&gt; github repo, so you don't need to install anything.&lt;/p&gt;

&lt;p&gt;So, with this:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "@openzeppelin/contracts/ownership/Ownable.sol";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;The compiler will search in the &lt;code&gt;contract&lt;/code&gt; folder of that repo, then in the &lt;code&gt;ownership&lt;/code&gt; folder and then grab the &lt;code&gt;Ownable.sol&lt;/code&gt; file and download it for you.&lt;/p&gt;

&lt;p&gt;Awesome, right? Well, &lt;strong&gt;you can do this with whatever file you want,&lt;/strong&gt; using the prefix to tell the compiler &lt;em&gt;“hey! If you see this (prefix) search it under this folder (the path)"&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Adding the dependencies section.
&lt;/h4&gt;

&lt;p&gt;To complete this, you can also add the &lt;code&gt;dependencies&lt;/code&gt; section to the brownie config file. This section will tell brownie to &lt;em&gt;install any listed dependencies prior to compiling a project.&lt;/em&gt; That could be useful when someone else download/clone your project from GitHub.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You just need to add the path of your remap to that dependencies section.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dependencies:
  - OpenZeppelin/openzeppelin-contracts@4.3.1
compiler:
  solc:
    remappings:
      - '@openzeppelin=OpenZeppelin/openzeppelin-contracts@4.3.1'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a &lt;code&gt;dependency&lt;/code&gt; folder under the &lt;code&gt;build/contracts&lt;/code&gt; folder. There, the artifacts of every dependencies that a contract need will be stored.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643850040466%2FqP1oX9mjW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643850040466%2FqP1oX9mjW.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The &lt;code&gt;build/contracts&lt;/code&gt; folder is where all the artifacts of the projects are stored.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you don't know, &lt;strong&gt;the artifacts are the result of the compiled contract, with all the objects that we can interact with, like the bytecode of the contract, the ABI, the address…&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you want to read more about the build folder you can check the &lt;a href="https://eth-brownie.readthedocs.io/en/stable/build-folder.html#the-build-folder" rel="noopener noreferrer"&gt;brownie documentation&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding new sections to grab information from.
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The brownie config file allows you to add new custom sections that you can use to store persistent data&lt;/strong&gt; that you could use all across your project. &lt;em&gt;You can do this in two different ways:&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Adding a simple section
&lt;/h4&gt;

&lt;p&gt;You just add a new section, you can call it whatever you want. Let's say you want to store your private key for deploy the contracts.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my_accounts:
    my_private_key: 'my_super_secret_private_key'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I add the section &lt;code&gt;my_accounts&lt;/code&gt; and inside that section a &lt;code&gt;my_private_key&lt;/code&gt; subsection and in that I store my private key.&lt;/p&gt;

&lt;p&gt;Also I could add more subsections to that section to store more data, example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my_accounts:
    my_private_key: 'my_super_secret_private_key'
    my_public_key: '0x02Ba39E868bF5140e572830C019c36843860B627'
    my_usename: 'kevinsito'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And even you could add a subsection inside a subsection, thats on you and whatever you want to do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And, you just can grab that information for use it in your scripts or your test files by using the brownie &lt;code&gt;config&lt;/code&gt; object.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You just need to import it &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from brownie import config

my_private_key = config["my_accounts"]["my_private_key"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The first, is the section, and the second is the subsection that we are searching.&lt;/p&gt;

&lt;p&gt;When you use it you will obtain the data that you store in your brownie config file under tat section.&lt;/p&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from Brownie import config

my_private_key = config["my_accounts"]["my_private_key"]

print(my_private_key)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643852559702%2F0S4-g0t5u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643852559702%2F0S4-g0t5u.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Obviously, you don't want to store your private key in that way, it is too dangerous…&lt;/strong&gt; Later in the article I will teach you how you can store in a more secure way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can literally do this with whatever section you want to grab information from&lt;/strong&gt;, not only with those you created. &lt;/p&gt;

&lt;h4&gt;
  
  
  Adding a section to grab information conditionally.
&lt;/h4&gt;

&lt;p&gt;You can also store information in the brownie config file, and grab it conditionally. For example:&lt;/p&gt;

&lt;p&gt;Let's say you only want to grab certain data when you are on the &lt;code&gt;rinkeby network&lt;/code&gt;, and other data when you are on the &lt;code&gt;kovan network&lt;/code&gt;. That could be a contract address.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;You could do that! *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Imagine your project needs to interact with a Chainlink contract, and you want to test it in all the different networks, but the address of that contract change depending on the network.&lt;/p&gt;

&lt;p&gt;So, you could add an address for the &lt;code&gt;kovan network&lt;/code&gt; and another for the &lt;code&gt;rinkeby network&lt;/code&gt; inside your brownie config file, and depending on the network you are deploying or testing your contract, one of those networks would be selected&lt;/p&gt;

&lt;p&gt;The brownie config file has a section in which you can modify all the networks default behavior, the &lt;code&gt;networks&lt;/code&gt; section. You could read more about all the specifications of the network section &lt;a href="https://eth-brownie.readthedocs.io/en/stable/config.html#networks" rel="noopener noreferrer"&gt;here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's do it!&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;networks:
    kovan:
        my_chainlink_contract_address: 'ths_is_my_chainlink_address_in_kovan'
    rinkeby:
        my_chainlink_contract_address: 'this_is_my_chainlink_address_in_rinkeby'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;And now, we can grab that information in our scripts or our test again by using the &lt;code&gt;config&lt;/code&gt; object of brownie&lt;/em&gt;, and specifying the section we want to grab information from.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from brownie import config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;contract_addresss=config["networks"]&lt;/p&gt;

&lt;p&gt;But now, &lt;strong&gt;how do we do this work depending on the network we are working?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can see what is the current network working with the brownie object &lt;code&gt;network&lt;/code&gt; and using its function &lt;code&gt;network.show_active()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This will tell us what is the current active network.&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;contract_address = config["networks"][network.show_active()]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And then, you need to add the name of the subsection that you created in the correspondent network, &lt;strong&gt;should be the same name between the networks.&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;contract_address = config["networks"][network.show_active()]["my_chainlink_contract_address"]

print(contract_address)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Let's test it.&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ brownie run scripts/testing.py --network rinkeby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643909213697%2Fjjcwl-wPL.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643909213697%2Fjjcwl-wPL.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now using kovan.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ brownie run scripts/testing.py --network kovan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643909283220%2Fzk07wc4yy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643909283220%2Fzk07wc4yy.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The flag &lt;code&gt;--network&lt;/code&gt; is used when we want to change to which network the contract would be deployed,* this is going to be the development network by default* (which is a ganache cli), you can read more about that &lt;a href="https://eth-brownie.readthedocs.io/en/stable/network-management.html#launching-and-connecting" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Okay but, how brownie knows how to change between networks by just typing its name?, well brownie have an object called &lt;code&gt;network&lt;/code&gt;, *&lt;em&gt;in which there stores a lot of different networks that we can use to deploy and test our contract. *&lt;/em&gt; &lt;em&gt;We will see more about that later in the article.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Using environment variables
&lt;/h2&gt;

&lt;p&gt;When you are working with smart contracts, &lt;strong&gt;there are certain data that you don't want the general public to know.&lt;/strong&gt; Like your private key, some API key, like your alchemy or infura API key.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To store that sensitive data we have a file called&lt;/strong&gt; &lt;code&gt;.env&lt;/code&gt; which is a file used to store environment variables and is not uploaded to Github.&lt;/p&gt;

&lt;p&gt;Lets create a &lt;code&gt;.env&lt;/code&gt; file in the root of our project.&lt;/p&gt;

&lt;p&gt;In this &lt;code&gt;.env&lt;/code&gt; file we can store sensitive data in variables, that we can use in other parts of the project, in a very secure way.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export MY_PRIVATE_KEY= &amp;lt;some_private_key&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We need to add the “export” keyword and the begining so brownie knows that variable can be used.&lt;/p&gt;

&lt;p&gt;And now, you can use that data in your scripts or test file, you just need to import the &lt;code&gt;os&lt;/code&gt; module&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os

my_private_key = os.getenv(“MY_PRIVATE_KEY”)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And by using the &lt;code&gt;.getenv&lt;/code&gt; method and passing the id of your environment variable as a parameter you can use that information in your files.&lt;/p&gt;

&lt;p&gt;Brownie by default writes in the &lt;code&gt;.gitignore&lt;/code&gt; file &lt;code&gt;.env&lt;/code&gt; to avoid that file been uploaded to github (you really don't want that) &lt;/p&gt;

&lt;p&gt;But you can check the &lt;code&gt;.gitignore&lt;/code&gt; file anyways to be sure that include&lt;code&gt;.env&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We also can use the environment variables in the&lt;/strong&gt; &lt;code&gt;brownie-config.yaml file&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let's say you want to store a private key to be able to grab it in your scrips. You can just type:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my_private key: ${MY_PRIVATE_KEY}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To be able to do that, you need to specify a new section in your brownie config file&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotenv: .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;With this we are saying to brownie &lt;em&gt;“hey, I want to use the &lt;code&gt;.env&lt;/code&gt; file as a file to store my environment variables, and whenever you see this strange character &lt;code&gt;${}&lt;/code&gt; in our brownie config file that's going to be an environmental variable that you can grab from the &lt;code&gt;.env&lt;/code&gt; file.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With that we can use our private key in a more secure way!.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And if you want to use the environment variables in your &lt;code&gt;.env&lt;/code&gt; file in all your project, you can do it by setting the environment variables using.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This will allow you yo use all the environment variables in your command line&lt;/p&gt;

&lt;p&gt;*This is my .env file *&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643908156730%2FZMvmkueOS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643908156730%2FZMvmkueOS.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can test this by typing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo $name_of_your_env_variable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643908193698%2FZF46Q-Vms.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643908193698%2FZF46Q-Vms.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Working with networks
&lt;/h2&gt;

&lt;p&gt;As I said earlier, &lt;strong&gt;you can use brownie to deploy your contract to a local or live networks.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You have two options here, &lt;strong&gt;you can use the development environment&lt;/strong&gt;, which is a  local, temporary network used for testing and debugging, is generating from Ganache. &lt;/p&gt;

&lt;p&gt;Or &lt;strong&gt;you can use a live environment&lt;/strong&gt;, a real blockchain. Could be a testnet or a real one.&lt;/p&gt;

&lt;p&gt;Brownie have a special object called &lt;code&gt;network&lt;/code&gt; that contains all the different default networks that we can use to deploy our contract. &lt;/p&gt;

&lt;p&gt;We can see all the networks that we have in brownie by typing:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ brownie networks list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This will show us all the different networks that we can use to deploy and test our contracts…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643909041398%2F84_73R1DhR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643909041398%2F84_73R1DhR.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see a more detailed list by adding "true"&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ brownie networks list true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643909070307%2FeD4pvbRrH.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643909070307%2FeD4pvbRrH.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this, &lt;strong&gt;you can see all the different options that the&lt;/strong&gt; &lt;code&gt;network&lt;/code&gt; &lt;strong&gt;object have.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And you can add new networks.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ brownie networks add [environment] [id] host=[host] [KEY=VALUE, ...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Network elements
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;environment:&lt;/strong&gt; the category that the network should be placed in, e.g. “Ethereum”, “Ethereum Classic”, or “Development”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;id:&lt;/strong&gt; a unique identifier for the network, e.g. “mainnet”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;host:&lt;/strong&gt; the address of the node to connect to, e.g. &lt;br&gt;
&lt;a href="https://mainnet.infura.io/v3/1234567890abcdef" rel="noopener noreferrer"&gt;https://mainnet.infura.io/v3/1234567890abcdef&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;port:&lt;/strong&gt; The port to connect to. If not given as a unique field, it should be included within the host path.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;accounts:&lt;/strong&gt; The number of funded, unlocked accounts. Default 10.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;mnemonic:&lt;/strong&gt; A mnemonic to use when generating local accounts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;fork:&lt;/strong&gt; If given, the local client will fork from another currently running Ethereum client. The value may be an HTTP location and port of the other client, e.g. &lt;br&gt;
&lt;a href="http://localhost:8545" rel="noopener noreferrer"&gt;http://localhost:8545&lt;/a&gt;, or the ID of a production network, e.g. mainnet. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;explorer:&lt;/strong&gt; the block explorer of that especific network.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are going to constantly use a network for deploying your project, and you don't want to add everytime the &lt;code&gt;--network&lt;/code&gt; flag &lt;strong&gt;you can set up the network that brownie is going to use by default&lt;/strong&gt; adding this section in your brownie config file.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;networks:
    default: ropsten
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;So the default network that brownie is going to use to deploy your contracts is going to be ropsten.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Of course, you can change that behavior in specific occations when you are deploying your contract.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ brownie run scripts/deploy.py --network rinkeby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;In this case the contract would be deployed on the rinkeby network&lt;/em&gt;, although the default network is ropsten.&lt;/p&gt;

&lt;p&gt;If you want to learn more about networks, you can read the &lt;a href="https://eth-brownie.readthedocs.io/en/stable/network-management.html" rel="noopener noreferrer"&gt;brownie documentation&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Adding forked network.
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Let me teach you how you can add a forked network:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That means, when you want to test your smart contract &lt;em&gt;you can literally grab a exact copy of the current ethereum mainnet and paste it for your personal use&lt;/em&gt;, &lt;strong&gt;so all the contracts that are in the mainnet you can use it in your project for testing without deploying mocks.&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ brownie networks add development my-super_mainnet-fork host=http://127.0.0.1 fork=http//:eth-mainnnet.alchemyapi/v2/&amp;lt;your alchemy project key&amp;gt; accounts=10 mnemonic=brownie port=8585
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Deleting an existing network.
&lt;/h3&gt;

&lt;p&gt;If you want to delete a default network or a network you created, you just have to type:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ brownie networks delete &amp;lt;id_of_the_network&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Remember you can know the id of all the networks by typing:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ brownie networks list true&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ brownie networks delete &amp;lt;ftm-main-fork&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1646365126644%2FgtT7vdFKt.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1646365126644%2FgtT7vdFKt.PNG" alt="Deleting network example"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Updating an existing network.
&lt;/h3&gt;

&lt;p&gt;If you want to change some value of a network, but without rewriting the entire network, you just need to type:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ brownie networks modify &amp;lt;id_of_the_network&amp;gt; key=value&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
Let's say you want to change the gas limit of the xdai network&lt;/p&gt;

&lt;p&gt;You just look for the network id and the element of the network you want to change and type:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ brownie networks modify xdai-main-fork gas_limit=210000000&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1646365524146%2F_QRjaA1Di.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1646365524146%2F_QRjaA1Di.PNG" alt="dos.PNG"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember not write when defining the key pair  &lt;/p&gt;

&lt;p&gt;✅ gas_lilmit=210000000&lt;br&gt;
❌ gas_limit = 210000000&lt;/p&gt;

&lt;p&gt;If you want to see more information about networks in the CLI you can always type:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ brownie networks --help&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Working with accounts.
&lt;/h2&gt;

&lt;p&gt;Brownie has a special object that allows us to interact with accounts (EOA) &lt;strong&gt;with this we can query a balance or send ether from a specific account.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For development purposes, brownie by default give us 10 accounts with false ether that we can use to test our smart contract in our ganache blockchain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Brownie also allow us to add accounts from our private key to the list of account in the brownie environment.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You can see your list of accounts by typing:&lt;/em&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ brownie accounts list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643909510496%2FrXqzH_3Yv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643909510496%2FrXqzH_3Yv.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You probably wouldn't have any account because first you need to add it.&lt;/p&gt;

&lt;p&gt;You can add an account in the list by using:&lt;/p&gt;

&lt;p&gt;$  brownie accounts generate &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This will  generate a random private key, and make the account available as .&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Brownie will ask you to choose a password to encrypt this account, so it is safe.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Also, you can import an account using its private key:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ brownie accounts new &amp;lt;id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You will be asked to input the private key, and to choose a password. The account will then be available as .&lt;/p&gt;

&lt;p&gt;You can see all the different method for manage account in brownie &lt;a href="https://eth-brownie.readthedocs.io/en/stable/account-management.html#local-accounts" rel="noopener noreferrer"&gt;here&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But wait, this is not dangerous? Could everyone see my private key?&lt;/strong&gt; Don't worry, browne encrypts your private key, so when you want to use that account brownie will ask you for your password to send transactions.&lt;/p&gt;

&lt;p&gt;To access those accounts in your scripts, you just need to import the &lt;code&gt;account&lt;/code&gt; object from brownie.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You can use the fake accounts that brownie generates.&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from brownie import accounts

my_account_1 = accounts[0]
my_account_2 = accounts[1]
my_account_3 =accounts[9]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Or, &lt;em&gt;you can load one of your accounts in your accounts list by using:&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from brownie import accounts

my_personal_account = accounts.load(id)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You provide the id of the account, and when sending the transactions brownie will ask you for the password of that account.&lt;/p&gt;

&lt;p&gt;Also you can import the account by using the private key of the account directly, using the &lt;code&gt;add&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;accounts.add(‘my private_key’)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can mix this method, using the&lt;/strong&gt; &lt;code&gt;.env&lt;/code&gt; &lt;strong&gt;file.&lt;/strong&gt; There you can store your private key, so you ensure it is not going to be uploaded to github.&lt;/p&gt;

&lt;p&gt;And then, in your brownie config file you can add a new section to store your private key using the name of that environment variable.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(remember you need to set the section”dotenv” to points to the .env file” so you can use environment variables in your brownie config file in that format)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643909984012%2FjsrNNx9sl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643909984012%2FjsrNNx9sl.png" alt="Brownie config file with new sections to store my private key."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And then, you grab your account  using the &lt;code&gt;conifg&lt;/code&gt; and &lt;code&gt;accounts&lt;/code&gt; object&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from brownie import config, account
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;my_account_from_private_key = accounts.add(config["wallets"]["from_key"])&lt;/p&gt;

&lt;p&gt;You can read more about how to work with accounts &lt;a href="https://eth-brownie.readthedocs.io/en/stable/core-accounts.html#working-with-accounts" rel="noopener noreferrer"&gt;here.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Function entry point.
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;This is something to take into account when you are writing your scripts.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Brownie looks for a function called&lt;/strong&gt; &lt;code&gt;main()&lt;/code&gt; &lt;strong&gt;as an entry point to run your scripts&lt;/strong&gt;, so if that function does not exist, you will get an error like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643910288185%2FbhmVOVun1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643910288185%2FbhmVOVun1.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can read more about that &lt;a href="https://eth-brownie.readthedocs.io/en/stable/interaction.html?highlight=scripts#writing-scripts" rel="noopener noreferrer"&gt;here.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Verify your contracts on etherscan
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;You can verify all the contract source code programmatically using brownie&lt;/strong&gt;, tis really easy.&lt;/p&gt;

&lt;p&gt;First, you need to create a Etherscan account &lt;/p&gt;

&lt;p&gt;&lt;a href="https://etherscan.io/register" rel="noopener noreferrer"&gt;Register on Etherscan.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Its like every registration process&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Then, you need to create an API key to be able to interact with the Etherscan API.&lt;/p&gt;

&lt;p&gt;In the nav bar, go to your profile and click in API keys.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643910798046%2FQ6BuWq4PK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643910798046%2FQ6BuWq4PK.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, you just need to add a new API key&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643910897877%2FxIXrp_ouN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1643910897877%2FxIXrp_ouN.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add that private key in your &lt;code&gt;.env&lt;/code&gt; file under.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export ETHERSCAN_TOKEN=&amp;lt;my_etherscan_token&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And for automatically verification you just need to add the argument &lt;code&gt;publish_source=True&lt;/code&gt; to the deploy function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from brownie import MyContractToken, accounts, config

my_account =  accounts.add(config["wallets"]["from_key"])

MyContractToken.deploy("My Contract Token", "CLT", 18, 1e28, {'from': my_account}, publish_source=True)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And you just need to run your deploy script.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Brownie run scripts/deploy.py --network rinkeby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Ta da! Your contract is already verified on Etherscan!&lt;/p&gt;

&lt;p&gt;It is even possible to verify contracts that you deployed earlier, as long as you didn’t change any of the code. This is done with:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;MyContractToken.publish_source(deployed_contract)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can read more about that &lt;a href="https://eth-brownie.readthedocs.io/en/stable/deploy.html#verifying-deployment-source-code" rel="noopener noreferrer"&gt;here.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Verifying contracts on other blockchains.
&lt;/h3&gt;

&lt;p&gt;Let's say you want to verify your contract on polygon, or BSC, or Fantom or  whatever EVM Based chain.&lt;/p&gt;

&lt;p&gt;The process is basically the same, you just need to go to the block explorer of that chain&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://bscscan.com" rel="noopener noreferrer"&gt;Binance explorer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://polygonscan.com/" rel="noopener noreferrer"&gt;Polygon explorer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://arbiscan.io/" rel="noopener noreferrer"&gt;Arbitrum explorer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create an account and create an API key that you have to paste in your .env file.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you get lost, follow the above tutorial using etherscan, as I said, the process is the same for most of the block explorers out there.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For name that env variable you have to take the name of the block explorer + “_” + “TOKEN”&lt;/p&gt;

&lt;p&gt;Example, let's say you have your polygon scan API, &lt;/p&gt;

&lt;p&gt;The env variable should be&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export POLYGONSCAN_TOKEN=&amp;lt;your_token&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;For know the name of a specific explorer in the in the brownie convention, use the list of accounts and look for the &lt;code&gt;explorer&lt;/code&gt; key pair the see its name&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But, how does Brownie know it has to use Etherscan to verify the contract?&lt;/p&gt;

&lt;p&gt;Well, remember the &lt;code&gt;networks&lt;/code&gt; object, in where we have a lot of networks to work with and all the especific elements that a network have?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;live:
  - name: Ethereum
    networks:
      - name: Ropsten (Infura)
        chainid: 3
        id: ropsten
        host: https://mainnet.infura.io/v3/$WEB3_INFURA_PROJECT_ID
        explorer: https://api-ropsten.etherscan.io/api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In that object there is a &lt;code&gt;explorer&lt;/code&gt; section that allow us to set the explorer to see the transactions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Brownie will knows that you would use the explorer that is under that section to verified your contracts&lt;/strong&gt;, and also give the links to be able to verify the transactions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That's all folks.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I hope this article was helpful for you.&lt;/p&gt;

&lt;p&gt;If you have any comment or suggestions, please leave it in the comments section.&lt;/p&gt;

&lt;p&gt;You can follow me on twitter &lt;a href="https://twitter.com/KevBto" rel="noopener noreferrer"&gt;@kevbto&lt;/a&gt; and DM me, I’m always happy to talk and get to know more people in this amazing community.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=M576WGiDBdQ" rel="noopener noreferrer"&gt;Free Code Camp Solidity course by Patrick Collins&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://eth-brownie.readthedocs.io/en/stable/index.html" rel="noopener noreferrer"&gt;The Brownie documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://iamdefinitelyahuman.medium.com/getting-started-with-brownie-part-1-9b2181f4cb99" rel="noopener noreferrer"&gt;Ben Hauser Borwnie guides&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://matnad.medium.com/how-to-verify-your-brownie-project-on-etherscan-82d6086644cf" rel="noopener noreferrer"&gt;How to verify your Brownie Project on Etherscan by matnad&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://chain.link/bootcamp/brownie-setup-instructions" rel="noopener noreferrer"&gt;Setup Instructions: Brownie Track by Chainlink&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pypa/pipx#pipx--install-and-run-python-applications-in-isolated-environments" rel="noopener noreferrer"&gt;pipx documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>web3</category>
      <category>solidity</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
