<?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 Daniel Fariña on Medium]]></title>
        <description><![CDATA[Stories by Daniel Fariña on Medium]]></description>
        <link>https://medium.com/@elchileno?source=rss-3d4b123fa7e5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*de9KVVITjaoeGViP2JCHPw.png</url>
            <title>Stories by Daniel Fariña on Medium</title>
            <link>https://medium.com/@elchileno?source=rss-3d4b123fa7e5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 10:33:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@elchileno/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[Setup a Starport Dapp & Cosmos Full Node with SSL (https/wss) endpoints via Nginx Reverse Proxy…]]></title>
            <link>https://medium.com/@elchileno/setup-a-starport-dapp-cosmos-full-node-with-ssl-https-wss-endpoints-via-nginx-reverse-proxy-861f28394f3c?source=rss-3d4b123fa7e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/861f28394f3c</guid>
            <category><![CDATA[cosmos-network]]></category>
            <category><![CDATA[starport]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[tendermint]]></category>
            <dc:creator><![CDATA[Daniel Fariña]]></dc:creator>
            <pubDate>Wed, 03 Nov 2021 16:06:34 GMT</pubDate>
            <atom:updated>2021-11-03T16:06:52.132Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setup a Starport Dapp &amp; Cosmos Full Node with SSL (https/wss) Endpoints via Nginx Reverse Proxy and Cloudflare.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mAh2PCwNSt8EUHifosRNbQ.png" /></figure><h3>Background</h3><p>Creating a Starport Dapp locally is pretty simple, it requires installing Golang, Starport, running a simple scaffold command to run your local chain , editing a .env file and executing the command to compile your VueJS dapp locally. <a href="https://docs.starport.com/">This is the official Starport documentation where this is covered in detail.</a></p><p>The next logical question is, how can I make it run on a cloud provider? <a href="https://medium.com/me/stats/post/b4b9593906fb">That’s answered here.</a></p><h3>Everything is going well until SSL is turned on.</h3><p>By default when the Starport VueJS dapp is uploaded to a hosting provider everything runs without SSL. One might think that it would be as simple as enabling SSL for your dapp via Cloudflare but the short answer is no. The Dapp requires a full node to connect to, the nodes usually run from the server’s IP address on specific port 26657 (http), 26657 (WebSockets) &amp; 1317 (http). For example:</p><p>Tendermint node: <a href="http://37.184.222.41:26657/">http://37.184.222.41:26657</a><br>Tendermint node WebSocket: ws://37.184.222.41:26657/websocket<br>Blockchain API: <a href="http://37.184.222.41:1317/">http://37.184.222.41:1317</a></p><p>It’s possible to replace the IP addresses with a domain via an A DNS entry in Cloudflare but that would only work with Cloudflare off. If the proxy status is turned on for the site only, all the API endpoints will be blocked by the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OyfNkkwW02Qp15vSOh9lpw.png" /></figure><p>The reason for this is Browsers do not allow a secure site to connect to unsecure APIs and Cloudflare only supports the following HTTPS ports by default as stated on their docs <a href="https://support.cloudflare.com/hc/en-us/articles/200169156-Identifying-network-ports-compatible-with-Cloudflare-s-proxy">here</a>.</p><ul><li>443</li><li>2053</li><li>2083</li><li>2087</li><li>2096</li><li>8443</li></ul><h3>How can we secure the full node endpoints?</h3><p>The following guide will show you how to setup your endpoints correctly with a reverse proxy. For this example I’m setting up a Dapp in a blockchain called Alien Chain (A chain our team is working on the side, to be announced soon).</p><p>The Alien Dapp is configured with a full node that is served via an Nginx reverse proxy to provide secure connections via Cloudflare SSL. I will assume familiarity creating servers in different cloud providers. I will use DigitalOcean in this particular example.</p><p>At the end of this guide you will end up with the following items running from a single server. In this example a Digital Ocean (37.184.222.41)</p><ul><li><a href="https://dapp.alien.blue/"><strong>https</strong>://dapp.alien.blue</a> (Front-end DApp)</li><li><a href="https://rest-ufo.alien.blue/"><strong>https</strong>://rest-ufo.alien.blue/</a> (Cosmos API on port 1317)</li><li><strong>wss</strong>://ws.alien.blue/websocket (Tendermint API Websocket)</li><li><a href="https://rest-ufo.alien.blue/"><strong>https</strong>://rest-ufo.alien.blue</a> (Tendermint API on port 26657)</li></ul><h3>Getting Started, Setup a Server &amp; Run a full node</h3><p>This step will require a new system user, install Golang, Clone the Alien’s blockchain repo, build it from source, create a systemd service and run it. <a href="https://app.gitbook.com/o/x8FUEgQefP3IU42WjEBb/s/PPjxDWyB9ugteqK3YcUc/guides/getting-started/running-a-full-node">Follow the instructions here</a> to run a full node of the Alien blockchain. You can also setup your own.</p><p>As stated earlier, the full node will then give you the following endpoints</p><p>Tendermint node: <a href="http://37.184.222.41:26657/"><strong>http</strong>://37.184.222.41:26657</a></p><p>Tendermint node WebSocket: <strong>ws</strong>://37.184.222.41:26657/websocket</p><p>Blockchain API: <a href="http://37.184.222.41:1317/"><strong>http</strong>://37.184.222.41:1317</a></p><p>Login to the server with the user created on the previous step.</p><pre>ssh alienuser@37.184.222.41</pre><h3>Clone the front-end Vue app repo</h3><p>On a starport application this folder lives inside your project.</p><pre>cd ~/<br>git clone <a href="https://github.com/alien-chain/vue">https://github.com/alien-chain/vue</a></pre><p>Create a new .env file from the sample</p><pre>cd ~/vue &amp;&amp; cp .env.spn .env</pre><p>edit the .env file. It should look like this:</p><pre>VUE_APP_API_COSMOS=http://37.184.222.41:1317/</pre><pre>VUE_APP_WS_TENDERMINT=ws://37.184.222.41:26657/websocket</pre><pre>VUE_APP_API_TENDERMINT=http://37.184.222.41:26657</pre><pre>VUE_APP_ADDRESS_PREFIX=alien</pre><pre>VUE_APP_CHAIN_ID=ufo</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9MCTU0eEq4ZVDJwlV4n5Zg.png" /></figure><h3>Build production Dapp</h3><p>If npm is not installed run</p><pre>sudo apt update<br>sudo apt install nodejs<br>sudo apt install npm</pre><p>Build production site</p><pre>npm install<br>npm run build</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sPPs6xuSHdVr62-bLs5wpQ.png" /></figure><p>The site lives in ~/vue and the production build folder is ~/vue/dist. The next step is to configure Nginx to to serve the site.</p><h3>DevOps Note</h3><p>In a production environment it would be better to setup a git action that builds our application and then deploys to the server after a commit to the master branch, but this guide is meant to get you up and running without all the overhead. It would be a better idea to setup the site in the /var/www directory as well but I’ll keep things simple in guide.</p><h3>Install Nginx</h3><p>This web server will serve our production dapp as well as route the api endpoints</p><pre>sudo apt update<br>sudo apt install nginx</pre><p>Allow firewall access, list app list</p><pre>sudo ufw app list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mDAXTTj8qrwU8R2c1hNGUw.png" /></figure><p>Allow Access to all Nginx</p><pre>sudo ufw allow ‘nginx full’</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w3buzoCWQYPJYilNePfniA.png" /></figure><p>Check status</p><pre>systemctl status nginx</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZMFC_T3jvNAmQNPF5EroPw.png" /></figure><p>Configure the server block for our Vue Dapp</p><pre>sudo nano /etc/nginx/sites-available/dapp.alien.blue</pre><p>Add the following</p><pre>server<br>{<br>listen 80;<br>listen [::]:80;<br>listen 443;</pre><pre>server_name dapp.alien.blue;<br>root /home/alienuser/vue/dist;<br>index index.html index.htm index.nginx.debian.html;</pre><pre>location /          {<br>try_files $uri $uri/ =404;<br>      }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Qs9PdeQjS1WedkrtpukCA.png" /></figure><h3>Create Symbolic Link for Nginx to Read on Startup</h3><p>Create a symbolic link between the server block and the startup directory</p><pre>cd /etc/nginx/sites-enabled<br>sudo ln -s ../sites-available/dapp.alien.blue .<br>ls -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2xHAojU2abz_4u2wC5FcVQ.png" /></figure><p>Restart Nginx</p><pre>sudo systemctl restart nginx</pre><p>Test Configuration</p><pre>sudo nginx -t</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*50lnxtTO9s7KN0NzIyTS5w.png" /></figure><h3>Configuring DNS entries</h3><p>In Cloudflare add the following entries. Note how the proxy status is turned off for now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VmE-hv3wIo7cEqN9" /></figure><h3>Test site</h3><p>The site is now accessible from <a href="http://dapp.alien.blue/">http://dapp.alien.blue</a></p><p>As you can see, the site is not served from https because we can’t run this dapp with https unless we also run all the blockchain endpoints via https. The next part will cover this part.</p><h3>Enabling SSL Cosmos Endpoints</h3><p>In order to serve the blockchain endpoints via https, we will setup a reverse proxy with Nginx.</p><h3>Enable reverse proxy for the Cosmos Rest API</h3><p>Create a new entry for the rest api. I will call this “rest-ufo”, the same as the Cloudflare entry</p><p>So the local instance of <a href="http://127.0.0.1:1317/"><strong>http://127.0.0.1:1317</strong></a> in the server will be served from <strong>rest-ufo.alien.blue</strong>;</p><pre>sudo nano /etc/nginx/sites-available/rest-ufo.alien.blue</pre><p>Paste the following:</p><pre>server {<br>        listen 80;<br>        listen [::]:80;<br>        listen 443;<br>        server_name rest-ufo.alien.blue;</pre><pre>access_log /var/log/nginx/rest-ufo.alien.blue-access.log;<br>        error_log /var/log/nginx/rest-ufo.alien.blue-error.log;</pre><pre>location / {<br>            <strong>proxy_pass</strong> <a href="http://127.0.0.1:1317/">http://127.0.0.1:1317</a>;<br>  }<br>}</pre><h3>Create Symbolic Link for Nginx to Read on Startup</h3><pre>cd /etc/nginx/sites-enabled<br>sudo ln -s ../sites-available/rest-ufo.alien.blue .<br>ls -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A1RHXnz52J2kdJKkOcxSCw.png" /></figure><p>Restart Nginx</p><pre>sudo systemctl restart nginx</pre><p>Test Configuration</p><pre>sudo nginx -t</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wGETDZhSQemyF_dp9I25LA.png" /></figure><p>Edit the app.toml</p><pre>nano ~/.alien/config/app.toml</pre><p>Make sure enabled-unsafe-cors is set to true for the [API]. This will allow all connections to your Cosmos API. This should only be used in testing networks. (This is something I have not been able to bypass with CORS rules in Nginx yet, if you know the answer please leave a comment below).</p><pre>enabled-unsafe-cors = true</pre><h3>Test Cosmos Rest API</h3><p>The site should be accessible from <a href="http://rest-ufo.alien.blue/">http://rest-ufo.alien.blue/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Hf-kVg_6cnamG5JilN2VQ.png" /></figure><h3>Enable reverse proxy for the Tendermint Rest API</h3><p>This is a similar process.</p><p>Create a new entry for the rest api. I will call this “rest-ufo”, the same as the Cloudflare entry</p><pre>sudo nano /etc/nginx/sites-available/rpc-ufo.alien.blue</pre><p>Paste the following:<br>Make sure to edit the server_name to match the configured domain name, and also to allow access from the official dap website only in this case <a href="https://dapp.alien.blue&/#39;"><strong>https://dapp.alien.blue</strong></a></p><pre>server {<br>        listen 80;<br>        listen [::]:80;<br>        listen 443;<br>        server_name <strong>rpc-ufo.alien.blue</strong>;<br>        access_log /var/log/nginx/rpc-ufo.alien.blue-access.log;<br>        error_log /var/log/nginx/rpc-ufo.alien.blue-error.log;</pre><pre>add_header &#39;Access-Control-Allow-Origin&#39; &#39;<a href="https://dapp.alien.blue&/#39;"><strong>https://dapp.alien.blue</strong>&#39;</a>;<br>        add_header &#39;Access-Control-Allow-Credentials&#39; &#39;true&#39;;<br>        add_header &#39;Access-Control-Allow-Headers&#39; &#39;Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range&#39;;<br>        add_header &#39;Access-Control-Allow-Methods&#39; &#39;GET,POST,OPTIONS,PUT,DELETE,PATCH&#39;;</pre><pre>location / {<br>                    proxy_pass <a href="http://127.0.0.1:26657/">http://127.0.0.1:26657</a>;<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z_CyYd_UCDciNhT11q667g.png" /></figure><h3>Create Symbolic Link for Nginx to Read on Startup</h3><pre>cd /etc/nginx/sites-enabled<br>sudo ln -s ../sites-available/rpc-ufo.alien.blue .<br>ls -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8YsW_nSiMBX4xXWPmaHM4A.png" /></figure><p>Restart Nginx</p><pre>sudo systemctl restart nginx</pre><p>Test Configuration</p><pre>sudo nginx -t</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*57mH1QnQhQxDMUQsMUkEYg.png" /></figure><p>At this point the tenderming rest api should be available via https</p><p><a href="https://rest-ufo.alien.blue/node_info">https://rest-ufo.alien.blue/node_info</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6OiHDg0kdnIcFkw43pFasw.png" /></figure><h3>Enable reverse proxy for the Tendermint Web Socket</h3><p>This part requires a special step. Since I can’t call a websocket directly from a proxy_pass, then first create a new entry for the web sockets API. I will call this “wsrest-ufo”.</p><p>Modify the nginx.conf</p><pre>sudo nano /etc/nginx/nginx.conf</pre><p>Add a new upstream to connect to the socket on port 26657 locally inside the http section.</p><pre>## web sockets proxy<br>        upstream websocket{<br>        server 127.0.0.1:26657;<br>        }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZeaqxDs_OZqXZPuhv5FtxQ.png" /></figure><p>Add a new entry for your custom reverse proxy. Note the proxy_pass calls the upstream defined above. Also update the domain name correspondingly.</p><pre>sudo nano /etc/nginx/sites-available/wsrpc-ufo.alien.blue</pre><p>Paste the following:</p><pre>server {<br>        listen 80;<br>        listen [::]:80;<br>        listen 443;<br>       server_name wsrpc-ufo.alien.blue;<br>        access_log /var/log/nginx/rpc-ufo.alien.blue-access.log;<br>        error_log /var/log/nginx/rpc-ufo.alien.blue-error.log;<br>        location / {<br>    proxy_pass <a href="http://websocket/">http://websocket</a>;<br>    proxy_http_version 1.1;<br>    proxy_set_header Upgrade $http_upgrade;<br>    proxy_set_header Connection &quot;upgrade&quot;;<br>    proxy_read_timeout 86400;<br>  }<br>}</pre><h3>Create Symbolic Link for Nginx to Read on Startup</h3><pre>cd /etc/nginx/sites-enabled<br>sudo ln -s ../sites-available/wsrpc-ufo.alien.blue .<br>ls -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fG_Udq3H2IHAaUxHWrdfyQ.png" /></figure><p>Restart Nginx</p><pre>sudo systemctl restart nginx</pre><p>Test Configuration</p><pre>sudo nginx -t</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Juu2hu93ttsRhuAapD3M8w.png" /></figure><p>Update your VUEJS .env and point it to your new secured endpoints</p><pre>nano ~/vue/.env</pre><p>It should look like this:</p><pre>VUE_APP_API_COSMOS=<a href="https://rest-ufo.alien.blue/">https://rest-ufo.alien.blue</a><br>VUE_APP_WS_TENDERMINT=wss://wsrpc-ufo.alien.blue/websocket<br>VUE_APP_API_TENDERMINT=<a href="https://rpc-ufo.alien.blue/">https://rpc-ufo.alien.blue</a><br>VUE_APP_ADDRESS_PREFIX=alien<br>VUE_APP_CHAIN_ID=ufo</pre><p>Rebuild your VUEJS App</p><pre>cd ~/vue<br>npm run build</pre><p>Make sure proxy is turned on for all related entries in Cloudflare.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_5MCR5lUlcvwuJnfTBXEiA.png" /></figure><p>The site and Blockchain endpoints are now accessible via https. Good job.</p><p>This guide was created because there is no documentation currently from the Cosmos SDK on how to setup a reverse proxy for the API endpoints.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=861f28394f3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up your Cosmos Blockchain Genesis]]></title>
            <link>https://medium.com/@elchileno/setting-up-your-cosmos-blockchain-genesis-8c54dd6de3b3?source=rss-3d4b123fa7e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c54dd6de3b3</guid>
            <category><![CDATA[cosmos]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[atom]]></category>
            <category><![CDATA[genesis]]></category>
            <category><![CDATA[starport]]></category>
            <dc:creator><![CDATA[Daniel Fariña]]></dc:creator>
            <pubDate>Sat, 30 Oct 2021 10:27:36 GMT</pubDate>
            <atom:updated>2021-10-30T10:27:36.432Z</atom:updated>
            <content:encoded><![CDATA[<p>There are several steps when it comes to creating a Cosmos Chain. The validators are the key and they must trust the genesis instead if trusting each other.</p><p>During the creation of the genesis.json for your blockchain, there will be tokens allocated. These allocations will be reviewed by validators. Once they are validated, they will sign gentxs transactions to be added as validators to the chain. All these gentx transactions will be collected in a single repository and then added to the genesis.json. At this point the genesis is sent out back to all validators for verification. Once all validators confirm the changes, they will start the nodes and start producing blocks.</p><p>In this guide I will show you how the creation of the genesis occurs with Starport and how it can be done manually with your Cosmos blockchain binary.</p><p>Follow the guide on the official site to install Starport: <a href="https://docs.starport.network/">https://docs.starport.network/</a></p><p><strong>Install startport</strong></p><pre>curl <a href="https://get.starport.network/starport!">https://get.starport.network/starport!</a> | bash</pre><p><strong>Create a new blockchain with Starport.</strong></p><pre>starport scaffold chain github.com/fugaz-chain/fugaz</pre><p>Let’s start by creating a brand new chain in your development environment. There are two ways to modify/create your genesis.</p><p><strong>Option A: Creating the genesis.json with Starport</strong></p><p>With startport you can create a chain with defined accounts on the config.yml file.</p><p>The config.yml file has the following contents</p><pre>accounts:<br>  - name: alice<br>    coins: [&quot;20000token&quot;, &quot;200000000stake&quot;]<br>  - name: bob<br>    coins: [&quot;10000token&quot;, &quot;100000000stake&quot;]<br>validator:<br>  name: alice<br>  staked: &quot;100000000stake&quot;<br>client:<br>  openapi:<br>    path: &quot;docs/static/openapi.yml&quot;<br>  vuex:<br>    path: &quot;vue/src/store&quot;<br>faucet:<br>  name: bob<br>  coins: [&quot;5token&quot;, &quot;100000stake&quot;]</pre><p>There one account for alice with 20000token and 200000000stake tokens. Alice is also defined as a validator. There is also bob with 10000token and 100000000stake and bob is identified as the coin faucet.</p><p>These two accounts were added to your local keying. You can manage these local accounts with the startport accounts command. <br>Learn more here: <a href="https://docs.starport.network/cli/#starport-account">https://docs.starport.network/cli/#starport-account</a></p><p><strong>Start the chain</strong></p><pre>starport chain serve</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-yf-8xk5u9ZxD8DpcSJyIQ.png" /></figure><p>This created two accounts defined on the config.yml file which are used on your dev environment.</p><p>This also did the following:</p><ul><li>Installs dependencies</li><li>Imports state, if possible</li><li>Builds protocol buffer files</li><li>Optionally generates JavaScript (JS), TypeScript (TS), and Vuex clients</li><li>Builds a compiled blockchain binary</li><li>Creates accounts</li><li>Initializes a blockchain node</li><li>Starts the following processes:</li><li>Tendermint RPC</li><li>Cosmos SDK API</li><li>Faucet, optional</li><li>Watches for file changes and restarts</li><li>Exports state</li></ul><p>More info: <a href="https://docs.starport.network/kb/serve.html#the-magic-of-starport-chain-serve">https://docs.starport.network/kb/serve.html#the-magic-of-starport-chain-serve</a></p><p><strong>Option B: Manually initialising and adding records to your genesis.json via your Blockchain’s compiled binary.</strong></p><p><strong>Build your Blockchain’s Binary</strong></p><pre>starport chain serve</pre><p><strong>Initialize the chain</strong></p><pre>fugazd init chainName --chain-id mychain</pre><p>Option A and Option B created a genesis file in ~/.fugaz/config/genesis.json. Go ahead and take a look at it:</p><pre>cat ~/.fugaz/config/genesis.json</pre><p>If you used Starport (<strong>Option A</strong>) you see there are two accounts with balances bob and alice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wwXJJ0MYR-lIcKvHczEuGg.png" /></figure><p>There is also a gentx transaction committed to the genesis that says that alice’s account is a validator</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VvbXdiiVBwZOUP-k6wCghQ.png" /></figure><p>Now if you decided to use <strong>Option B, </strong>you will get a genesis without any accounts or validators added to them, how can you add them or define them?</p><p>Adding a new account locally and then to your genesis.</p><p>Add account called <strong>user1</strong> to your local keyring.</p><p>Learn more about keyring here:<a href="https://docs.cosmos.network/master/run-node/keyring.html">https://docs.cosmos.network/master/run-node/keyring.html</a></p><pre>fugazd keys add <strong>user1</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sVUX7FOTkG8NXISYq4LjPQ.png" /></figure><p>Check the account has been added to your local keyring</p><pre>fugazd keys list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IIEUsD75xvJp4TiNJ0vEoA.png" /></figure><h3>Adding the new account to the genesis</h3><p>Now the account is not in the genesis yet. How about adding this new account to the genesis?</p><pre>fugazd add-genesis-account fugaz1rgaquupsvmm59g0v9gf85n8g94n5ll79fux7pu 10000000ufugaz</pre><p>Check to see if it was added to the Genesis.json</p><pre>cat ~/.fugazd/config/genesis.json</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dZZ4q6Jt52Fz24nbDLgg-w.png" /></figure><p>Check on the UI (Dapp). Import the wallet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nBCuhbOaKXTxg48uapjlog.png" /></figure><p>Enter the mnemonic that was given to you on the console when you created the account</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MSDPpI8U0yS82Hg_nnvmXA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oOTQXZks38WBZetmf0890A.png" /></figure><p>You should now see the account on your dapp</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*hTj2tDFe9856fBGkyuM_Tw.png" /></figure><p>How about adding validators to the genesis? That’s a different topic covered here.</p><p><a href="https://medium.com/@elchileno/how-to-join-a-testnet-as-a-validator-on-cosmos-based-blockchain-83bee8df96d3">How to Join a Testnet as a Validator on Cosmos Based Blockchain.</a></p><p>Follow me on Twitter: <a href="https://twitter.com/Daniel_Farinax">https://twitter.com/Daniel_Farinax</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c54dd6de3b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Join a Testnet as a Validator on Cosmos Based Blockchain.]]></title>
            <link>https://medium.com/@elchileno/how-to-join-a-testnet-as-a-validator-on-cosmos-based-blockchain-83bee8df96d3?source=rss-3d4b123fa7e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/83bee8df96d3</guid>
            <category><![CDATA[cosmos]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[testnet]]></category>
            <category><![CDATA[starport]]></category>
            <dc:creator><![CDATA[Daniel Fariña]]></dc:creator>
            <pubDate>Sat, 30 Oct 2021 07:10:55 GMT</pubDate>
            <atom:updated>2021-10-30T07:58:15.529Z</atom:updated>
            <content:encoded><![CDATA[<p>In the Cosmos ecosystem, it’s important to understand the role of a testnet. Before launching the mainnet of a blockchain a series of testnets are created in order to test the genesis, validators, simulate upgrades, etc. This is where validators that are looking to participate on the mainnet get a chance to contribute and learn about becoming validators with a testnet.</p><p>The best place to learn is by looking at the launch process of other testnets such. For example: <a href="https://github.com/CosmosContracts/testnets">https://github.com/CosmosContracts/testnets</a></p><p>In this example I will join a blockchain called <strong>alien-chain. </strong>Each chain has a unique chain-id. Our chain id will be called <strong>ufo</strong>. This guide is meant for people who are building a blockchain and are trying to understand the process that validators will go through in order to join a testnet.</p><p><strong>This guide will walk you through the following process:</strong></p><ul><li>Setting up the server (Ubuntu, will be used for this Example)</li><li>Install Starport on the server</li><li>Install the Blockchain’s Binary from source.</li><li>Create a local account</li><li>Initialize the Genesis</li><li>Adding the validator address and balance to the genesis (not required as a validator but important to understand for the team managing the chain launch).</li><li>Create a gentx transaction file</li><li>Submit the Gentx to the Chain’s Testnet Repository</li></ul><p><strong>Background</strong></p><p>The purpose of this guide is to go into as many details as possible in order to explain the process of joining a testnet in a Cosmos based blockchain. Do not expect this to be as simple as running one command on a server. Practice is your friend.</p><p><em>This Alien blockchain is work in progress and will be officially announced in a couple of weeks. (I guess you know first about it now </em>🤫<em>). The idea is to share as much as possible while working on it and hopefully attract other people to join the project. More details will be available soon.</em></p><p>Recommended Skills</p><ul><li>Reading Cosmos’ Starport : <a href="https://starport.com/">https://starport.com/</a></li><li>Reading Cosmos’s Documentation: <a href="https://docs.cosmos.network/">https://docs.cosmos.network/</a></li><li>Linux/Server management : <a href="https://www.digitalocean.com/community/tutorials/an-introduction-to-linux-basics">Learn the basics here</a></li><li>Basic git command skills : <a href="https://www.digitalocean.com/community/tutorial_series/introduction-to-git-installation-usage-and-branches">Introduction to Git</a></li></ul><h3>Setting up a Server</h3><p>Let’s start by creating a brand new server on DigitalOcean. If this . Use this tutorial as reference <a href="http://tutorials.cosmos.network/publish-app-do/">here</a>. This step can be skipped the if the blockchain is already running on a server and you are familiar with managing it.</p><p>Select Ubuntu 20.4, Shared CPU, $12/month 2gb Memory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kjnkQuL0DT02waye.png" /></figure><p>Select all the default options except for the size. I selected a $12/month server to run things a little smoother. I also recommend connecting via SSH keys. You can learn more about this <a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-2">here</a>.</p><p>Login to<strong> </strong>the newly created server. The first time you login with your ssh-key you will be asked to accept the server to list of known hosts.</p><pre>ssh root@128.199.6.43</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kbuK5BxC_B545eJyhXhTnw.png" /></figure><p>Create a new user. I’m calling this user “<strong>valuser</strong>” (Make sure to save the user’s sudo password).</p><pre>adduser <strong>valuser</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JZ02e8832a8E4xF_SKb2EQ.png" /></figure><p>Adding Sudo User from Usermod Command</p><pre>usermod -aG sudo <strong>valuser</strong></pre><p>To be able to login as valuser, copy the ssh public key to the new home directory for valuser:</p><pre>rsync --archive --chown=valuser:valuser ~/.ssh /home/valuser</pre><p>Switch to the new user. Next time you login to the server, use <br>ssh valuser@128.199.6.43.</p><pre>su - valuser</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IWHlpYewInL7Je6kuJdbsw.png" /></figure><p>Install Golang, you will be asked for the valuser’s password.</p><pre>wget <a href="https://golang.org/dl/go1.17.2.linux-amd64.tar.gz">https://golang.org/dl/go1.17.2.linux-amd64.tar.gz</a><br>sudo tar -xvf go1.17.2.linux-amd64.tar.gz -C /usr/local<br>sudo chown -R valuser:valuser /usr/local/go</pre><p>Add Go to the paths in the local profile:</p><pre>nano ~/.profile</pre><p>At the end of the file add the following:</p><pre>export GOPATH=$HOME/go<br>export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WakVFyjDUgeoxbMi_l54BA.png" /></figure><p>Command + x to exit, then type “<strong>yes</strong>” to save changes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*woqW66b6QWxHUiQ-Zfd0sQ.png" /></figure><p>Refresh the profile &amp; check version</p><pre>source ~/.profile<br>go version</pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pj3R9ppBMZQsf4taiMvB7w.png" /></figure><h3>Install Starport on the server</h3><pre>curl <a href="https://get.starport.network/starport!">https://get.starport.network/starport!</a> | sudo bash</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SlnssfuyXV-tQS9psuXZsQ.png" /></figure><h3>Install the Blockchain’s Binary from source.</h3><p>Download the alien-chain’s repo and build the binary from source.</p><pre>cd ~/<br>git clone <a href="https://github.com/alien-chain/alien.git">https://github.com/alien-chain/alien.git</a><br>cd alien<br>starport chain build</pre><p>The aliend binary was installed and it’s ready for user’s inputs.</p><h3>Create a local account</h3><p>An account is a pair of a private key and a public key.</p><p>What is keyring-backend?</p><p>The keyring holds the private/public keypairs used to interact with a node. For instance, a validator key needs to be set up before running the blockchain node, so that blocks can be correctly signed. The private key can be stored in different locations, called “backends”, such as a file or the operating system’s own key storage.</p><p>There are different types of backends for keyring. In this case we are using the test keyring for testing purposes. Please learn more about the different types available on the <a href="https://docs.cosmos.network/master/run-node/keyring.html#available-backends-for-the-keyring">Cosmos documentation</a>.</p><p>Add a local account</p><pre>aliend keys add validator_one --keyring-backend test</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F3oS7RrEzffn7M-HI3qfzQ.png" /></figure><p>List the current accounts on this system</p><pre>aliend keys list --keyring-backend test</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2xswstSVp0o12szblVJDfA.png" /></figure><p>— — — — — DELETE FROM TUTORIAL</p><p>Create a local variable to get the validator address</p><pre>MY_VALIDATOR_ADDRESS=$(aliend keys show validator_one -a --keyring-backend test)</pre><p>Test the variable</p><pre>echo $MY_VALIDATOR_ADDRESS</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EoafWEc_0Ks2Zy4DMOKY-Q.png" /></figure><h3>Init the Genesis</h3><pre>aliend init ufo --chain-id=ufo</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MRDMXEBpNra_c93suWoNTQ.png" /></figure><p>The genesis filehas been created, however it does not have a validator in it. It’s just an empty genesis we will use to generate a gentx file that will be submitted to the Alien’s chain repository to be consolidated into a single genesis with all of the validator addresses, balances and gentx.</p><p>⚠️ <strong>These next two steps are not necessary on this tutorial but it’s important to understand.</strong></p><h3>Adding the validator address and balance to the genesis</h3><p>1. In order for the gentx to be accepted, the address and balance of the validator must exist in the genesis. The chain’s team will run the following command to add the validator account to the genesis. Where <strong>alien1lh5zzm7r4vx6jx5x4qmqs889gkzk6xr30jqy60</strong> was generated when the “aliend keys add” was executed.</p><pre>aliend add-genesis-account alien1lh5zzm7r4vx6jx5x4qmqs889gkzk6xr30jqy60 100000000000stake</pre><p>2. They will follow this by running another command to add the gentx file you will submit to the repository. This command processes the gentx files and adds them as actual transactions on the genesis.</p><pre>aliend collect-gentxs</pre><p>⚠️ Ok, continuing with the tutorial.</p><h3>Create a gentx transaction file</h3><p>A genesis transaction that lives locally in the ~/.alien/config.gentx folder.</p><pre>aliend gentx validator_one 100000000stake --chain-id ufo --keyring-backend test</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hwS0hQ3-T1smFFpD4txLIQ.png" /></figure><h3>Submit the Gentx to the Chain’s Testnet Repository</h3><p>Most Cosmos projects will have a repo that will contain the genesis for their testnets and another repo that contains geneses and gentx for the mainnet. In this example we will fork the testnet called ufo in the Alien chain project.</p><p>Fork the <a href="https://github.com/alien-chain/testnets">alien-chain/testnets</a> repo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0g5FcSJleuBQdZcMHhtoCg.png" /></figure><p>Download the forked repo to the server’s home directory. If you don’t know what a fork is, or how to submit a PR from your fork to the original repo, this would be a good time to learn the git basics. I’ll try to explain this as much as possible.</p><pre>cd ~/<br>git clone https://github.com/daniel-farina/<a href="https://github.com/alien-chain/testnets.git">testnets.git</a></pre><p>Copy the gentx transactions that was created on the previous step to this repo’s genx folder.</p><pre>cp ~/.alien/config/gentx/gentx-ac8ec7ccd1b0bd531ad6bfa628e1e7128f0216d8.json ~/testnets/ufo/gentx/</pre><p>Basically a new gentx transaction will be added to your fork of the testnet repo from the Alien-chain which we will then submit to the alien-chain repo via a pull request.</p><p>The file has been added but not added to the repo. gentx-ac8ec7ccd1b0bd531ad6bfa628e1e7128f0216d8.json is the name of the gentx transaction. It will be a different name in your server. Add the file by running this command. Make sure that this name matches the file that was just copied on the previous step.</p><pre>cd ~/testnets<br>git add ufo/gentx/gentx-ac8ec7ccd1b0bd531ad6bfa628e1e7128f0216d8.json</pre><p>Check your git repository status. A new file has been added to this repo</p><pre>git status</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P1aqDqsOmggCUEjL_wCThA.png" /></figure><p>Commit changes (Include your validator’s name on the commit title possible)</p><pre>git commit -m &quot;Adding gentx for Validator&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LpcEWzX7mqmKSDEKWRcawA.png" /></figure><p>Push the commits to Github. If you are not logged in to Github, then login with your email and token. <a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token">Learn how to obtain a token here.</a></p><p>If this is a brand new server, configure the Github email and name.</p><pre>git config --global user.email &quot;<a href="/service/mailto:you@example.com">you@example.com</a>&quot;<br>git config --global user.name &quot;Your Name&quot;</pre><p>Now push the changes.</p><pre>cd ~/testnets<br>git push</pre><p>A Github username and token will be required to login. Password do not work, it must be a generated token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NSb4YYu0XS-5SCar5zaauA.png" /></figure><p>Then the changes are uploaded to the forked repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0wV6_myG7X7iJ_cEmwiIag.png" /></figure><p>Create a PR (Pull Request) from Github to add the changes from your fork into the alien-chain’s repo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ff-CMr8t9GRvAw_-2FtIHg.png" /></figure><p>Click create new pull request. Make sure the correct file is sent on this pull request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nUVnsbDQfH30JDuJ7UKfqg.png" /></figure><p>Add a nice title and description.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A96etmgWx-S4uVGF8fRzYg.png" /></figure><p>That’s it. Now the team will review this testnet and add it to the main genesis which will be used and shared with all validators once the testnet is launched.</p><p>How about running the Blockchain on the server?</p><p>To learn how to run this blockchain on the server make sure to view this other guide :<a href="https://medium.com/@elchileno/deploy-cosmos-starport-dapp-to-digitalocean-b4b9593906fb">https://medium.com/@elchileno/deploy-cosmos-starport-dapp-to-digitalocean-b4b9593906fb</a></p><p>Thank you!</p><p>Follow me on Twitter: <a href="https://twitter.com/Daniel_Farinax">https://twitter.com/Daniel_Farinax</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83bee8df96d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Cosmos/Starport Dapp to DigitalOcean]]></title>
            <link>https://medium.com/@elchileno/deploy-cosmos-starport-dapp-to-digitalocean-b4b9593906fb?source=rss-3d4b123fa7e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4b9593906fb</guid>
            <category><![CDATA[atom]]></category>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[starport]]></category>
            <category><![CDATA[cosmos-network]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Daniel Fariña]]></dc:creator>
            <pubDate>Sun, 24 Oct 2021 10:41:28 GMT</pubDate>
            <atom:updated>2021-10-24T10:41:28.977Z</atom:updated>
            <content:encoded><![CDATA[<p>The base VUE application that comes in Cosmos’ Starport can be run locally via npm run serve. However what would be a fast way to test it in production or an staging environment? It’s important to understand this process before considering automating it with Terraform, build and release pipelines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ckH8ivMETMu8on60hgx4Lg.png" /></figure><p><strong>Warning: </strong>This is meant to provide an understanding of how a Cosmos Dapp could run in a cloud provider. There are additional things are are not covered on this guide such as security, ssl certificates configuration, etc.</p><p>This is a continuation of the guide from yesterday that covered how to manually deploy your blockchain to multiple nodes. <a href="https://medium.com/@elchileno/create-a-cosmos-starport-blockchain-with-two-nodes-in-digitalocean-4ef278dc540f">You can see that guide here.</a></p><p>At first you might think running it on the same node where the blockchain was created on the previous but I believe that would not be a good practice. Specially if a small DigitalOcean droplet is used while testing. It will run out of memory quite quickly.</p><p>A good solution would be creating a separate repository for the Vue Dapp application, creating a Git action to build a production release and then deploying the production release to a web server of choice. However, In this example I will share how to quickly get it up and running on a DigitalOcean droplet with a light weight PM2 http instance. We will then configure a domain name for it.</p><h3><strong>Step 1</strong></h3><p>Create a new DigitalOcean droplet. You can use any cloud provider. I will call this DigitalOcean droplet <strong>appServer </strong>with ip<strong> 134.122.28.115 . </strong>Select one with at least two GB of memory to prevent running into issues with npm. Add your SSH key for easy passwordless access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZapipmoWKsDFT4GoB4CbMQ.png" /></figure><h3>Step 2</h3><p>Login to <strong>appServer</strong></p><pre>ssh root@134.122.28.115</pre><h3>Step 3</h3><p>Create a new user called “<strong>appuser</strong>” to run the application with. (Make sure to save the user’s password).</p><pre>adduser <strong>appuser</strong></pre><p>Then run</p><pre>usermod -aG sudo <strong>appuser</strong></pre><p>To be able to login as appuser, copy the ssh public key to the new home directory for appuser:</p><pre>rsync --archive --chown=appuser:appuser ~/.ssh /home/appuser</pre><p>Switch to the new user</p><pre>su - appuser</pre><p>update apt</p><pre>sudo apt update<br></pre><p>Install npm</p><pre>sudo apt install npm</pre><h3><strong>Step 4</strong></h3><p>Clone the repository that contains the Vue app. In this case we will clone the entire starport repository I created on the previous guide which was created during the scaffolding.</p><pre>git clone <a href="https://github.com/daniel-farina/myblockchain.git">https://github.com/daniel-farina/myblockchain.git</a></pre><p>Navigate to the vue directory</p><pre>cd myblockchain/vue</pre><p>Install npm dependencies</p><pre>npm install</pre><h3><strong>Step 6</strong></h3><p>Configure the environment file. Copy the sample <strong>.env.spn</strong> as <strong>.env</strong> in your vue directory.</p><pre>cp .env.spn .env</pre><p>Edit the urls for the Tendermint API, BlockChain API, Address Prefix, Chain ID, Chain Name.</p><p>For example the VUE_APP_API_COSMOS would be your Blockchain API on port 1317. VUE_APP_API_TENDERMINT is lives on port 26657</p><pre>VUE_APP_API_COSMOS=http://159.223.108.208:1317<br>VUE_APP_WS_TENDERMINT=ws://159.223.108.208:26657/websocket<br>VUE_APP_API_TENDERMINT=http://159.223.108.208:26657/<br>VUE_APP_ADDRESS_PREFIX=cosmos<br>VUE_APP_CHAIN_ID=spn<br>VUE_APP_CHAIN_NAME=&quot;Starport Network&quot;</pre><p>Build production.</p><pre>npm run build</pre><h3><strong>Step 5</strong></h3><p>Start a simple web server with PM2</p><p>Install PM2</p><pre>npm install pm2@latest -g</pre><p>Start the <strong>pm2</strong> web server on the <strong>dist</strong> folder on port <strong>80</strong></p><pre>cd dist<br>sudo pm2 serve --spa --name app --port 80</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9h7XKe7iV4zZbMSLS4fBZQ.png" /></figure><p>See the free monitor pm2 comes with</p><pre>sudo pm2 monit</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTRHpSRLBDq3PN0PatDV7w.png" /></figure><p>You can manage the process with <strong>pm2 delete|restart|stop app.</strong></p><p>Learn more about this neat PM2 option here: <a href="https://pm2.keymetrics.io/docs/usage/expose/">https://pm2.keymetrics.io/docs/usage/expose/</a></p><h3><strong>Step 6</strong></h3><p>Access your Dapp on the web browser. The Dapp would be accessible on the ip address of your DigitalOcean server. For example <a href="https://134.122.28.115/">http://134.122.28.115</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ckH8ivMETMu8on60hgx4Lg.png" /></figure><h3><strong>Step 7</strong></h3><p>Setup your Dapp the run behind a domain name. This assumes you are familiar with Cloudflare.</p><p>Go to your Cloudflare Account and add a domain name. Select the free option. Create an A record and point it to your IP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L_XjyuD6dQh1mCbBMoy8UA.png" /></figure><p>You should now be able to open the website with your domain name.</p><h3><strong>Step 8</strong></h3><p>This is optional. Setup your Tendermint API, BlockChain API to run behind a domain name. Currently the APIs are accessible via the IP address. In order make them accessible via a domain name just add an A record on your domain name pointing them to the Blockchain API.</p><p>Edit your .env. In this example I will call them rpc.alpha &amp; rest.alpha so you will end up with a configuration like this:</p><pre>VUE_APP_API_COSMOS=http://<strong>rest-alpha.fugaz.network</strong>:1317<br>VUE_APP_WS_TENDERMINT=ws://<strong>rpc-alpha.fugaz.network</strong>:26657/websocket<br>VUE_APP_API_TENDERMINT=http://<strong>rpc-alpha.fugaz.network</strong>:26657/<br>VUE_APP_ADDRESS_PREFIX=cosmos<br>VUE_APP_CHAIN_ID=spn<br>VUE_APP_CHAIN_NAME=&quot;Starport Network&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BPozUBvkPpKwKW5c2lUGTw.png" /></figure><p>In order for the changes to take effect in production rebuild it and restart the pm2 process.</p><p>Note that <strong>app </strong>is the name of the PM2 process and it must be ran with sudo.</p><pre>npm run build<br>sudo pm2 restart app</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2cWvvLF1v2PkD_2OF2pAmw.png" /></figure><p>The application should be accessible via your domain name.</p><p>In this example it would be: <a href="http://fugaz.network/">http://fugaz.network/</a> if you open the console you will see it’s calling the domain name instead if the IP.</p><p>Please make sure to visit the <a href="https://starport.com/">Starport</a> website to learn how to get started developing a Cosmos Blockchain &amp; Dapp.</p><p>TODO: SSL</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4b9593906fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I created a Cosmos Blockchain with Starport running two nodes on DigitalOcean]]></title>
            <link>https://medium.com/@elchileno/create-a-cosmos-starport-blockchain-with-two-nodes-in-digitalocean-4ef278dc540f?source=rss-3d4b123fa7e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ef278dc540f</guid>
            <category><![CDATA[cosmos-network]]></category>
            <category><![CDATA[starport]]></category>
            <category><![CDATA[cosmos-sdk]]></category>
            <category><![CDATA[cosmos]]></category>
            <category><![CDATA[cosmostation]]></category>
            <dc:creator><![CDATA[Daniel Fariña]]></dc:creator>
            <pubDate>Fri, 22 Oct 2021 08:29:29 GMT</pubDate>
            <atom:updated>2021-10-25T19:28:55.570Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the concepts that was difficult to understand when I first started interacting with Cosmos’ Starport was the fact that the application creates a Binary file. This file can be distributed for additional peers to connect to the blockchain.</p><p>In this example, I’m going to create two servers which I will call <strong>firstNode</strong> &amp; <strong>secondNode</strong> respectively. The first node will run thestarport serve command to build the Cosmos blockchain, create a genesis file, and the configuration. I can do this in the local environment but the purpose of this post is to get the Cosmos blockchain up and running with two nodes on DigitalOcean. I will then publish the application to Github, take a look at the automatic release process, download the release to <strong>secondNode</strong> and connect to <strong>firstnode </strong>from the<strong> secondNode.</strong></p><p>Lastly, I will also run the blockchain locally (This part is pending as first I want to focus on two nodes onDigitalOcean).</p><p>The result will be the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hDep9iM_IXDtk3vqgVpmDA.png" /></figure><h3><strong>Step 1</strong></h3><p>Let’s start by creating two servers on DigitalOcean. If you don’t know how to do this. You can reference the tutorial that helped me understand this <a href="http://tutorials.cosmos.network/publish-app-do/">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uxPhd2gxZ2TdzHsrpFu7OQ.png" /></figure><p>Select all the default options except for the size. I selected a $12/month server to run things a little smoother. I also recommend connecting via SSH. You can learn more about this <a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-2">here</a>.</p><p>Then create two droplets at once by selecting the add droplet button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rzEESg1nSsgvLF8s-s3mtg.png" /></figure><p>Once this is complete I will have two servers ready to configure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OnGiEPYZp5Lgi9qWNsf7lA.png" /></figure><h3><strong>Step 2</strong></h3><p>Login to <strong>firstNode</strong></p><pre>ssh root@159.223.108.208</pre><h3><strong>Step 3</strong></h3><p>Create a new user called “<strong>first_user</strong>” to run the application with. (Make sure to save the user’s password).</p><pre>adduser <strong>first_user</strong></pre><p>Adding Sudo User from Usermod Command</p><pre>usermod -aG sudo <strong>first_user</strong></pre><p>To be able to login as first_user, copy the ssh public key to the new home directory for first_user:</p><pre>rsync --archive --chown=first_user:first_user ~/.ssh /home/first_user</pre><p>Switch to the new user</p><pre>su - first_user</pre><h3><strong>Step 4</strong></h3><p>Install Golang</p><pre>wget <a href="https://golang.org/dl/go1.17.2.linux-amd64.tar.gz">https://golang.org/dl/go1.17.2.linux-amd64.tar.gz</a></pre><pre>sudo tar -xvf go1.17.2.linux-amd64.tar.gz -C /usr/local</pre><pre>sudo chown -R first_user:first_user /usr/local/go</pre><p>Add Go to the paths in the localprofile:</p><pre>nano ~/.profile</pre><p>At the end of the file add the following:</p><pre>export GOPATH=$HOME/go<br>export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin</pre><p>Refresh the profile &amp; check version</p><pre>source ~/.profile<br>go version</pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*RAbCMCNb6ET8Iaw70ry-oA.png" /></figure><h3><strong>Step 5</strong></h3><p>Install Starport on the firstNode</p><pre>curl https://get.starport.network/starport! | sudo bash</pre><h3><strong>Step 6</strong></h3><p>Create Starport application on the <strong>firstNode</strong> which I will call “<strong>myblockchain</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*QkQhGgqAdm6sdFQqOkYgVA.png" /></figure><pre>cd ~/<br>starport scaffold chain github.com/daniel-farina/myblockchain</pre><p><strong>Start the application on the firstNode in development mode</strong></p><pre>cd ~/myblockchain<br>starport chain serve</pre><p>This will create new accounts, add tokens to them and configure the blockchain. More about this on the official documentation information <a href="https://docs.starport.com/kb/serve.html#the-magic-of-starport-chain-serve">here</a>.</p><p>This also runs the blockchain in development mode. If you cancel or exit this window the blockchain will stop running. You would usually run this locally when coding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H_g615q4BuqVOo7SFUBSvg.png" /></figure><p>By the way, the configuration for the first two wallets, validators and faucet for the development environment lives on the config.yml.</p><p>The process of adding accounts to your testnet/mainnet requires you to use the add-genesis-account command for your blockchain. There is not a lot documentation about this yet but you can get an idea from <a href="https://hub.cosmos.network/main/resources/genesis.html">here.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GeG6xjEo1Dvln9OqGBTbCg.png" /></figure><h3><strong>Step 7</strong></h3><p>I created a binary of myblockchain in the firstNode</p><pre>cd ~/blockchain<br>starport chain build</pre><p>This will add myblockchain<strong>d </strong>to<strong> </strong>the Go’s bin folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7DIDnQpVkXaT3stfJlb-EA.png" /></figure><p>I can now start the blockchain anywhere in the system with:</p><pre>myblockchaind start</pre><h3><strong>Step 8</strong></h3><p>Create a systemd process for myblockchaind</p><p>First, create some necessary files</p><pre>sudo mkdir -p /var/log/myblockchaind <br>sudo touch /var/log/myblockchaind/digitaloceand.log <br>sudo touch /var/log/myblockchaind/myblockchaind_error.log <br>sudo touch /etc/systemd/system/myblockchaind.service</pre><p>Second, edit the systemd service file for myblockchaind.</p><pre>sudo nano /etc/systemd/system/myblockchaind.service</pre><p>Next, add the following configuration to it:</p><pre>Description=myblockchaind daemon<br>After=network-online.target<br>[Service]<br>User=first_user<br>ExecStart=/home/first_user/go/bin/myblockchaind start --home=/home/first_user/.myblockchain<br>WorkingDirectory=/home/first_user/go/bin<br>StandardOutput=file:/var/log/myblockchaind/digitaloceand.log<br>StandardError=file:/var/log/myblockchaind/digitaloceand_error.log<br>Restart=always<br>RestartSec=3<br>LimitNOFILE=4096<br>[Install]<br>WantedBy=multi-user.target</pre><p>Then, enabled it to run all the time even after it reboots.</p><pre>sudo systemctl enable myblockchaind.service</pre><p>Start the process.</p><pre>sudo systemctl start myblockchaind.service</pre><p>Lastly, I can see the logs of the new service like this:</p><pre>sudo journalctl -u myblockchaind -f</pre><h3><strong>Step 9</strong></h3><p>Create a Github repo and push the code to it. This step is quite important. I will use the automatic actions from github to build a public release of the blockchain.</p><p>Create an empty github repo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*salBXJFJHEtgoAatzuCd7g.png" /></figure><p>Add remote and push changes</p><pre>git remote add origin https://github.com/daniel-farina/myblockchain.git<br>git push -u origin master</pre><p>If asked to login, enter the username and token. A token must be created <a href="https://github.com/settings/tokens">here </a>and used instead of the account password. Make sure to select <strong>repo access</strong> and <strong>workflow access</strong>. I recommend deleting that token from the account once it’s not longer needed.</p><p>A repo with the base Starport app is now ready.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CgJFOvnprgZeP6xZp_u4Jg.png" /></figure><h3><strong>Step 10</strong></h3><p><strong>Automatic Release</strong></p><p>The team behind Starport created a neat Github action to automatically build the application.</p><p>Go to the repo and click the <strong>Actions tab</strong>. As you can see, a git action is automatically executed once a commit is pushed to the main branch. This git action lives in .github/workflows/release.yml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rdYmQ7CVMB66Q-pqKh08vA.png" /></figure><p>This action will run the <strong>release.yml</strong> which has several steps to build and release the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rFDBxykbP4-db6jQv-uvBQ.png" /></figure><p>The release in the repo contains a distribution binary for the blockchain:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PccZ8N2PFHCLTmjjHtpAgQ.png" /></figure><h3><strong>Step 11</strong></h3><p>Start a <strong>secondNode</strong> on DigitalOcean</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*jTMYwX0PHmX0G6RQ_dPJGQ.png" /></figure><p>Download this release and start a new node.</p><p>Login to the <strong>secondNode</strong></p><pre>ssh <strong>second_user</strong>@159.223.98.102</pre><p>Create a new user called “<strong>second_user</strong>” to run the application with. Make sure to the save the user’s password.</p><pre>adduser <strong>second_user</strong><br>usermod -aG sudo <strong>second_user</strong></pre><p>To be able to login as second_user, copy the ssh public key to the new home directory for second_user:</p><pre>rsync --archive --chown=second_user:second_user ~/.ssh /home/second_user</pre><p>Switch to the new user</p><pre>su - second_user</pre><p><strong>Repeat step 4 &amp; 5 (Install Go &amp; Starport)</strong></p><p>At this point there should be two consoles running. The firstNode with systemd and the secondNode ready for our next action.</p><h3><strong>Step 12.</strong></h3><p>This section will cover installing the blockchain onto another server, initialising it and then adding it to systemd.</p><p><strong>Install myblockchaind in the system </strong><a href="https://docs.starport.com/kb/serve.html#start-a-blockchain-node-in-production">Learn more</a>.</p><p>The binary can be installed using utility from Starport. Replace the bold text with the repo’s info.</p><pre><br>curl <a href="https://get.starport.network/daniel-farina/myblockchain@latest">https://get.starport.network/<strong>daniel-farina/myblockchain</strong>@latest</a>! | sudo bash</pre><p><strong>Or</strong> the repo can be cloned and built on the secondNode directly.</p><pre>cd ~/<br>git clone <a href="https://github.com/daniel-farina/myblockchain">https://github.com/daniel-farina/myblockchain</a><br>cd <a href="https://github.com/daniel-farina/myblockchain">myblockchain</a><br>starport chain build</pre><p>Initialize the node so all the necessary myblockchain files and directories get created</p><pre>myblockchaind init <strong>{MONIKER}</strong></pre><ul><li><strong>Moniker:</strong> The name of the validator (e.g. “secondNode”)</li></ul><p>Next copy the genesis from the <strong>firstNode</strong> (<strong>/home/first_user/.myblockchain/config/genesis.json</strong>) machine to the <strong>secondNode </strong>server<strong>.</strong></p><p>In production it’s a good idea to create a repo with the genesis for testnet and mainnet. You can see an example of this on the Terra repo <a href="https://github.com/terra-money/mainnet">here</a>.</p><p>On this example however, I will use the <strong>scp</strong> command to copy the genesis from firstnode to <strong>secondNode</strong>, a ssh-key is needed on the <strong>firstNode</strong></p><p>Generate a key pair for the <strong>firstNode &amp; secondNode</strong></p><pre>ssh-keygen</pre><p>Then get the public key from <strong>firstNode</strong></p><pre>cat ~/.ssh/id_rsa.pub</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*moFczOHaHsTOS1_8nmgkmg.png" /></figure><p>Add the public key to the <strong>secondNode</strong> (at the end of the file)</p><pre>nano ~/.ssh/authorized_keys</pre><p>Now back to the firstNode, copy the genesis from it to the secondNode.</p><pre>scp /home/<strong>first_user/</strong>.<strong>myblockchain</strong>/config/genesis.json <strong>second_user</strong>@159.223.98.102:/home/<strong>second_user</strong>/.<strong>myblockchain</strong>/config/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nx_hr_vi9FfXbeiq6xS5Qg.png" /></figure><p>Configure a persistent connection with the <strong>secondNode</strong> instance.</p><p>On another window in the <strong>firstNode</strong> machine run the following command to get the node-id.</p><pre>myblockchaind tendermint show-node-id</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4n4gGJvJCNrSmo8jW4KCpA.png" /></figure><p>Then add the <strong>firstNode</strong> node-id and IP into the configuration file on the <strong>secondNode</strong>.</p><p>Edit the server’s config.toml on the <strong>secondNode</strong></p><pre>nano ~/.myblockchain/config/config.toml</pre><p>Add a persistent connection. Use the node-id from the <strong>firstNode, </strong>IP address and default port.</p><pre># Comma separated list of nodes to keep persistent connections to persistent_peers = &quot;148c4d60de49ad6bacbf9abe3c51608f217403c4@159.223.108.208:26656&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47PeuCn7JvBannDsdfyPfQ.png" /></figure><p>Start the blockchain on the <strong>secondNode</strong></p><pre>myblockchaind start</pre><p>The blockchain on secondNode is now syncing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dbG6QW4gav7wwzbNUPrBHg.png" /></figure><p>To verify that the nodes are connected. Open the terminal on the <strong>firstNode </strong>and run this command:</p><pre>go get -u github.com/cosmos/gex<br>gex</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6VMk5fRBINN1-Brffw4CA.gif" /></figure><p>Success! the connected peers should show a number <strong>1</strong> which means the blockchain is successfully running on two nodes. 🎉</p><h3><strong>Step 13</strong></h3><p>Finally, I’m going to add secondNode to systemd as well so that it can be running automatically at all times. This is a repeat of step 8.</p><p>Create a systemd process for myblockchaind</p><p>First, create some necessary files</p><pre>sudo mkdir -p /var/log/myblockchaind <br>sudo touch /var/log/myblockchaind/digitaloceand.log <br>sudo touch /var/log/myblockchaind/myblockchaind_error.log <br>sudo touch /etc/systemd/system/myblockchaind.service</pre><p>Second, edit the systemd service file for myblockchaind.</p><pre>sudo nano /etc/systemd/system/myblockchaind.service</pre><p>Next, add the following configuration to it:</p><pre>Description=myblockchaind daemon<br>After=network-online.target<br>[Service]<br>User=<strong>second_user</strong><br>ExecStart=/home/<strong>second_user</strong>/go/bin/myblockchaind start --home=/home/<strong>second_user</strong>/.myblockchain<br>WorkingDirectory=/home/<strong>second_user</strong>/go/bin<br>StandardOutput=file:/var/log/myblockchaind/digitaloceand.log<br>StandardError=file:/var/log/myblockchaind/digitaloceand_error.log<br>Restart=always<br>RestartSec=3<br>LimitNOFILE=4096<br>[Install]<br>WantedBy=multi-user.target</pre><p>Then, enabled it to run all the time even after it reboots.</p><pre>sudo systemctl enable myblockchaind.service</pre><p>Start the process.</p><pre>sudo systemctl start myblockchaind.service</pre><p>Lastly, I can see the logs of the new service like this:</p><pre>sudo journalctl -u myblockchaind -f</pre><h4><strong>Done! Stay tuned for more guides.</strong></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ef278dc540f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>