@ -887,207 +887,7 @@ KeyPairUtil | Generated new key <key> and stored it to ~/pantheon/build/di
<p>After you're finished running the demo, you can stop the Pantheon client by returning to the terminal window that runs the node and entering <code>Ctrl+c</code>.</p>
<p>After you're finished running the demo, you can stop the Pantheon client by returning to the terminal window that runs the node and entering <code>Ctrl+c</code>.</p>
<p>This tutorial describes how to use Pantheon to run a private network of Pantheon nodes in a Docker container.</p>
<p>Refer to the <ahref="https://github.com/PegaSysEng/pantheon/wiki/Docker-Quickstart">Pantheon Wiki</a> for the Docker Quickstart Tutorial. </p>
<blockquote>
<p><strong>Note</strong> To run the Docker Quickstart, you must install Pantheon by <ahref="https://github.com/PegaSysEng/pantheon/wiki/Installation">cloning and building</a>. </p>
<p>If you have installed Pantheon from the <ahref="https://pegasys.tech/">packaged binaries</a> or are running the <ahref="https://hub.docker.com/u/pegasyseng/">Docker image</a>, continue with <ahref="#Quickstart">Basic Quickstart</a> or <ahref="#Starting-Pantheon">Starting Pantheon</a>.</p>
</blockquote>
<h2id="prerequisites">Prerequisites</h2>
<p>To run this tutorial, you must have the following installed:</p>
<ul>
<li><p>Linux or Mac OS</p>
</li>
<li><p><ahref="https://docs.docker.com/compose/install/">Docker and Docker-compose</a></p>
<li><p>A web browser that supports <ahref="https://metamask.io/">Metamask</a> (currently Chrome, Firefox, Opera, and Brave), and has the MetaMask plug-in installed. This tutorial uses screenshots from Brave.</p>
<p>As indicated in <ahref="#Installationclone-the-pantheon-repository">the installation section</a>,
clone the repository.</p>
<h2id="build-docker-images-and-start-services-and-network">Build Docker Images and Start Services and Network</h2>
<p>This tutorial uses <ahref="https://docs.docker.com/compose/">Docker Compose</a> to simplify assembling images and
running in a private network. To run the containers, go to the <code>pantheon</code> directory and run the following shell command:</p>
<preclass="hljs">quickstart/runPantheonPrivateNetwork.sh</pre><p>This script builds Pantheon, builds the images and runs the containers. It will also scale the regular node container to four containers to simulate a network with enough peers to synchronize.</p>
<p>When the <code>quickstart/runPantheonPrivateNetwork.sh</code> script ends, it lists the running services:</p>
quickstart_bootnode_1 /opt/pantheon/bootnode_sta ... Up <spanclass="hljs-number">30303</span>/tcp, <spanclass="hljs-number">30303</span>/udp, <spanclass="hljs-number">8084</span>/tcp, <spanclass="hljs-number">8545</span>/tcp
quickstart_explorer_1 /bin/sh -c npm start Up <spanclass="hljs-number">0.0</span><spanclass="hljs-number">.0</span><spanclass="hljs-number">.0</span>:<spanclass="hljs-number">32770</span>-><spanclass="hljs-number">3000</span>/tcp
quickstart_minernode_1 /opt/pantheon/node_start.s ... Up <spanclass="hljs-number">30303</span>/tcp, <spanclass="hljs-number">30303</span>/udp, <spanclass="hljs-number">8084</span>/tcp, <spanclass="hljs-number">8545</span>/tcp
quickstart_node_1 /opt/pantheon/node_start.s ... Up <spanclass="hljs-number">30303</span>/tcp, <spanclass="hljs-number">30303</span>/udp, <spanclass="hljs-number">8084</span>/tcp, <spanclass="hljs-number">8545</span>/tcp
quickstart_node_2 /opt/pantheon/node_start.s ... Up <spanclass="hljs-number">30303</span>/tcp, <spanclass="hljs-number">30303</span>/udp, <spanclass="hljs-number">8084</span>/tcp, <spanclass="hljs-number">8545</span>/tcp
quickstart_node_3 /opt/pantheon/node_start.s ... Up <spanclass="hljs-number">30303</span>/tcp, <spanclass="hljs-number">30303</span>/udp, <spanclass="hljs-number">8084</span>/tcp, <spanclass="hljs-number">8545</span>/tcp
quickstart_node_4 /opt/pantheon/node_start.s ... Up <spanclass="hljs-number">30303</span>/tcp, <spanclass="hljs-number">30303</span>/udp, <spanclass="hljs-number">8084</span>/tcp, <spanclass="hljs-number">8545</span>/tcp
quickstart_rpcnode_1 /opt/pantheon/node_start.s ... Up <spanclass="hljs-number">30303</span>/tcp, <spanclass="hljs-number">30303</span>/udp, <spanclass="hljs-number">8084</span>/tcp,
<spanclass="hljs-number">0.0</span><spanclass="hljs-number">.0</span><spanclass="hljs-number">.0</span>:<spanclass="hljs-number">32769</span>-><spanclass="hljs-number">8545</span>/tcp, <spanclass="hljs-number">0.0</span><spanclass="hljs-number">.0</span><spanclass="hljs-number">.0</span>:<spanclass="hljs-number">32768</span>-><spanclass="hljs-number">8546</span>/tcp</pre><p>And a friendly recap of the entrypoints :</p>
<li>Use the <strong>JSON-RPC HTTP service endpoint</strong> to access the RPC node service from your Dapp or from cryptocurrency wallets such as Metamask.</li>
<li>Use the <strong>JSON-RPC WebSocket service endpoint</strong> to access the web socket node service from your Dapp.</li>
<li>Use the <strong>Web block explorer address</strong> to display the block explorer web application. You can invoke the block explorer by clicking on the endpoint link or by entering the URL in your web browser.</li>
<p>This tutorial uses a block explorer based on <ahref="https://github.com/mix-blockchain/block-explorer.git">the MIX project explorer</a>.</p>
<blockquote>
<p><strong>Note:</strong> As Yarn is an Apache 2.0 licensed tool, it has been patched to fit this tutorial's needs. (You can view the patches in the quickstart/explorer folder.)</p>
</blockquote>
<h3id="using-the-block-explorer-with-metamask">Using the Block Explorer with MetaMask</h3>
<p>Log in to MetaMask if you don't already have it running. The block explorer displays the network to which MetaMask is connected. If you see a <strong>Peer Count</strong> of 100 in the block explorer, it's likely MetaMask is connected to mainnet or one of the testnets such as Ropsten.</p>
<p>To display the private network in the block explorer, you have to configure a custom RPC network.</p>
<p>After you sign in to MetaMask, connect to the private network RPC endpoint by:</p>
<ol>
<li>In the MetaMask network list, select <strong>Custom RPC</strong>.</li>
<li>In the <strong>New RPC URL</strong> field, enter the <code>JSON-RPC HTTP service endpoint</code> displayed when you started the private network.</li>
</ol>
<p>Save the configuration and return to the MetaMask main screen. Your current network is now set to the private network RPC node.</p>
<h3id="using-the-block-explorer-without-metamask">Using the Block Explorer without MetaMask</h3>
<p>If you don't have Metamask running, the block explorer works directly without configuration. The block explorer integrates its own web3 version and knows the RPC node endpoint.</p>
<h3id="run-the-block-explorer">Run the Block Explorer</h3>
<p>Access the explorer using the <code>Web block explorer address</code> displayed when starting the private network.</p>
<p>You can run RPC requests on <code>rpcnode</code>, the node that is exposed to the host in order to listen for requests.</p>
<p>In this tutorial, note that the <code>http://localhost:http-rpc-port</code> placeholder is <code>http://localhost: 32769</code>.</p>
<blockquote>
<p><strong>Note:</strong> Make sure to replace <code>port</code> with the one provided in the <code>quickstart/listQuickstartServices.sh</code> command <code>JSON-RPC HTTP service endpoint</code>.
The dynamic docker port mapping changes each time you run the network.</p>
</blockquote>
<h3id="requesting-the-node-version">Requesting the Node Version</h3>
<p>Run the following command from the host shell :</p>
<preclass="hljs">curl -X POST --data <spanclass="hljs-string">'{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}'</span> http://localhost:http-rpc-port</pre><p>The result should be as follows: </p>
}</pre><p>Here we simply query the version of the Pantheon node, which confirms the node is running.</p>
<p>Now if this works, let's see some more interesting requests.</p>
<h3id="counting-peers">Counting Peers</h3>
<p>Peers are the number of other nodes connected to the RPC node.</p>
<p>Poll the peer count using <code>net_peerCount</code>:</p>
<preclass="hljs">curl -X POST --data <spanclass="hljs-string">'{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}'</span> http://localhost:http-rpc-port</pre><p>The result should be the following response, indicating that there are 6 peers:</p>
}</pre><h3id="requesting-the-most-recent-mined-block-number">Requesting the Most Recent Mined Block Number</h3>
<p>This provides the count of blocks already mined.</p>
<p>To do so, call <code>eth_blockNumber</code> to retrieve the number of the most recent block:</p>
<preclass="hljs">curl -X POST --data <spanclass="hljs-string">'{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'</span> http://localhost:http-rpc-port</pre><p>The result of this call should be:</p>
}</pre><p>Here the hexadecimal value <code>0x8b8</code> translates to <code>2232</code> in decimal; that many blocks have already been mined.</p>
<h3id="checking-the-miner-account-balance-coinbase-">Checking the Miner Account Balance (Coinbase)</h3>
<p>Then call <code>eth_getBalance</code> to retrieve the balance of the mining address defined in the miner node:</p>
<preclass="hljs">curl -X POST --data <spanclass="hljs-string">'{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","latest"],"id":1}'</span> http://localhost:http-rpc-port</pre><p>The result of this call should be something like :</p>
}</pre><p><em>0x79f905c6fd34e80000 = 2250000000000000000000 Wei (2250 Ether)</em> (you can use a unit <ahref="https://etherconverter.online/">converter</a> )</p>
<p>Wait a few seconds until new blocks are mined and make this call again. The balance should increase,
meaning that the miner address successfully received the mining reward.</p>
<p><em>Also you can see this information in the block explorer. It does exactly the same thing as we
did manually, connecting to the rpc node using http JSON-RPC, but displays information on a web page.</em></p>
<li>Initial balance : 0x90000000000000000000000 (2785365088392105618523029504 in decimal)</li>
</ul>
<blockquote>
<p><strong>Note:</strong> Pantheon does not provide an accounts management system, so if you want to create your own account, you will have to use a third party tool like Metamask.</p>
</blockquote>
<h3id="creating-a-transaction-using-metamask">Creating a Transaction Using MetaMask</h3>
<p>Once you have <ahref="#configure-a-custom-rpc-network-in-metamask">Configured a custom RPC network</a>, <ahref="https://consensys.zendesk.com/hc/en-us/articles/360004176551-Importing-an-Account-New-UI-">import one of the existing accounts above into
metamask</a>
using the corresponding private key. </p>
<p><strong>NOTE that here we don't really care about securing the keys as it's just a tutorial, but be sure
to secure your accounts when you run into a real usecase. This will be discussed in a more advanced
chapter.</strong></p>
<p>Once this is done, try to <ahref="https://consensys.zendesk.com/hc/en-us/articles/360004774951-Creating-Additional-MetaMask-Wallets-New-UI-">create another account from scratch</a>
to send some ether to.</p>
<p><em>Of course remember that here we are dealing with valueless ether as we are not
on the main network but on a local private network.</em></p>
<p><ahref="https://consensys.zendesk.com/hc/en-us/articles/360005055472-Sending-Ether-New-UI-">Send some ether</a>
from the first account (containing some ether) to the new one (that have a zero balance)
and go to the explorer to check that your transaction is validated.</p>
<p>You should see a block in the list with one transaction, and you can look at the detail of the block
<h3id="playing-with-the-truffle-pet-shop-tutorial">Playing with the Truffle Pet Shop Tutorial</h3>
<p>This step is inspired by <ahref="https://truffleframework.com/tutorials/pet-shop">the PetShop tutorial on Truffle website</a>.</p>
<p>Use the following instructions to run it with the quick-start Pantheon Docker network and a wallet to manage keys.</p>
<h4id="prerequisites">Prerequisites</h4>
<ul>
<li>Install Truffle :</li>
</ul>
<preclass="hljs">npm install -g truffle</pre><ul>
<li>Grab the tutorial <ahref="https://truffleframework.com/tutorials/pet-shop#creating-a-truffle-project-using-a-truffle-box">as indicated in the Truffle site</a>:</li>
};</pre><p>Then replace the <code>[YOUR HTTP RPC NODE ENDPOINT]</code> placeholder with your HTTP RPC node endpoint. <code>http://localhost:32769</code> in this case.</p>
<p>The private address indicated in the file is the miner address so we know we will have funds in it. You don't need to change it.</p>
<p>Once this is done, you can go through the regular tutorial steps.</p>
<p>When you have to run a truffle command, you only have to indicate the right network to use, as in the following command using the <code>--network quickstartWallet</code> option :</p>
<preclass="hljs">truffle migrate --network quickstartWallet</pre><p>Your are then able to see the transactions and contracts deployed on your local docker network if you have a look in the block explorer.</p>
<h2id="shut-down-the-network-and-remove-the-nodes">Shut Down the Network and Remove the Nodes</h2>
<p>To shut down the network, you can use the script <code>quickstart/removePantheonPrivateNetwork.sh</code>; this will stop and destroy all containers.</p>
<p>Pantheon nodes can be used for varying purposes as described in the <ahref="#Overview">Overview</a>. Nodes can connect to the Ethereum mainnet, public testnets such as Ropsten, or private networks.</p>
<p>Pantheon nodes can be used for varying purposes as described in the <ahref="#Overview">Overview</a>. Nodes can connect to the Ethereum mainnet, public testnets such as Ropsten, or private networks.</p>