<?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>Forem: Michael Assaf</title>
    <description>The latest articles on Forem by Michael Assaf (@michaelassaf).</description>
    <link>https://forem.com/michaelassaf</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%2F974669%2F12eb066d-7c10-4031-9a1c-9adf029970ab.jpg</url>
      <title>Forem: Michael Assaf</title>
      <link>https://forem.com/michaelassaf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/michaelassaf"/>
    <language>en</language>
    <item>
      <title>How to launch a private local substrate blockchain</title>
      <dc:creator>Michael Assaf</dc:creator>
      <pubDate>Tue, 10 Jan 2023 17:07:23 +0000</pubDate>
      <link>https://forem.com/michaelassaf/substrate-tutorial-launching-a-private-local-blockchain-1phf</link>
      <guid>https://forem.com/michaelassaf/substrate-tutorial-launching-a-private-local-blockchain-1phf</guid>
      <description>&lt;p&gt;In this tutorial, you'll see how to launch your own private local blockchain with trusted participants. &lt;/p&gt;

&lt;p&gt;What you will learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;generate the keys required to authorize a node to participate in the network&lt;/li&gt;
&lt;li&gt;how to configure and share information about the network with other authorized accounts&lt;/li&gt;
&lt;li&gt;how to launch the network with an approved set of validators&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Prerequisites:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install &lt;a href="https://www.rust-lang.org/tools/install"&gt;Rust&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Clone the &lt;a href="https://github.com/substrate-developer-hub/substrate-node-template"&gt;substrate node template&lt;/a&gt; repository&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Start basic nodes with default accounts (optional)
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;If you are familiar with substrate and running nodes using default accounts like &lt;code&gt;alice&lt;/code&gt;, you can skip to the next section.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Start a local node using the &lt;code&gt;alice&lt;/code&gt; account by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./target/release/node-template &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--base-path&lt;/span&gt; /tmp/alice &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--chain&lt;/span&gt; &lt;span class="nb"&gt;local&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--alice&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--port&lt;/span&gt; 30333 &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--ws-port&lt;/span&gt; 9945 &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--rpc-port&lt;/span&gt; 9933 &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--node-key&lt;/span&gt; 0000000000000000000000000000000000000000000000000000000000000001 &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--telemetry-url&lt;/span&gt; &lt;span class="s2"&gt;"wss://telemetry.polkadot.io/submit/ 0"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--validator&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start a second local node using the &lt;code&gt;bob&lt;/code&gt; account to connect to the local network:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./target/release/node-template &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--base-path&lt;/span&gt; /tmp/bob &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--chain&lt;/span&gt; &lt;span class="nb"&gt;local&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--bob&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--port&lt;/span&gt; 30334 &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--ws-port&lt;/span&gt; 9946 &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--rpc-port&lt;/span&gt; 9934 &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--telemetry-url&lt;/span&gt; &lt;span class="s2"&gt;"wss://telemetry.polkadot.io/submit/ 0"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--validator&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--bootnodes&lt;/span&gt; /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--bootnodes&lt;/code&gt; option specifies the following information:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ip4&lt;/code&gt; indicates that the IP address for the node uses the IPv4 format&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;127.0.0.1&lt;/code&gt; specifies the IP address for the running node&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tcp&lt;/code&gt; specifies TCP as the protocol used for peer-to-peer communication&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;30333&lt;/code&gt; specifies the port number used for peer-to-peer communication&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp&lt;/code&gt; identifies the running node to communicate with for this network&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can validate that both nodes are now on the same network by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;verifying the genesis block hash is the same for both node outputs&lt;/li&gt;
&lt;li&gt;the first local node discovered the second one
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2023-01-09 17:21:08 discovered: 12D3KooWCzPnRRYHyVh2TQy2VaqmqxCkaFKGXhcscUhvJotrZsAE /ip4/10.0.0.144/tcp/30334    
2023-01-09 17:21:08 discovered: 12D3KooWCzPnRRYHyVh2TQy2VaqmqxCkaFKGXhcscUhvJotrZsAE /ip4/10.1.43.0/tcp/30334 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To purge local chain data, run the following command.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;./target/release/node-template purge-chain --base-path /tmp/bob --chain local -y&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note that the base path will be different depending on which account was used to start the local node.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Launching private network blockchain
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Adding trusted nodes
&lt;/h2&gt;

&lt;p&gt;Adding trusted nodes to our network requires us to generate an account with keys for each node.&lt;br&gt;
To generate a key using the &lt;code&gt;node-template&lt;/code&gt;, run the following command.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;./target/debug/node-template key generate --scheme Sr25519 --password-interactive&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once you input your password, you should have a similar output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Secret phrase:       hen corn install jaguar spring pink neck squeeze account enough ahead bounce
  Network ID:        substrate
  Secret seed:       0xd4883e547610a9543e1f68db1100833f3f57586b0e7a70437c84cb558ecd7cbe
  Public key (hex):  0x42e88babfc903a7f3c12e576f52288144487f019ff9d2605df0f558c617a6909
  Account ID:        0x42e88babfc903a7f3c12e576f52288144487f019ff9d2605df0f558c617a6909
  Public key (SS58): 5DaS6dzomvqS3MpKcKgxz54GgEJje5Y11L1PHjyeMVniBrEM
  SS58 Address:      5DaS6dzomvqS3MpKcKgxz54GgEJje5Y11L1PHjyeMVniBrEM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Polkadot uses &lt;a href="https://wiki.polkadot.network/docs/learn-cryptography#keypairs-and-signing"&gt;sr25519&lt;/a&gt; for its key derivation and signing algorithm. &lt;br&gt;
The &lt;code&gt;aura&lt;/code&gt; consensus protocol (proof of authority) will use the &lt;code&gt;sr25519&lt;/code&gt; public key &lt;code&gt;5DaS6dzomvqS3MpKcKgxz54GgEJje5Y11L1PHjyeMVniBrEM&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: The Substrate node template uses a proof of authority consensus model also referred to as authority round or Aura consensus. The **Aura consensus protocol&lt;/em&gt;* limits block production to a rotating list of authorized accounts. The authorized accounts—authorities—create blocks in a round robin fashion and are generally considered to be trusted participants in the network.*&lt;/p&gt;

&lt;p&gt;Since &lt;code&gt;grandpa&lt;/code&gt; uses &lt;strong&gt;Ed25519&lt;/strong&gt; as its key format, we will also derive the public key using the following command:&lt;/p&gt;

&lt;p&gt;Use the secret phrase that was generated for you in the previous command.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;./target/debug/node-template key inspect --password-interactive --scheme Ed25519 "hen corn install jaguar spring pink neck squeeze account enough ahead bounce"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Secret phrase:       hen corn install jaguar spring pink neck squeeze account enough ahead bounce
  Network ID:        substrate
  Secret seed:       0xd4883e547610a9543e1f68db1100833f3f57586b0e7a70437c84cb558ecd7cbe
  Public key (hex):  0x128ea392292f8be6682543ee87e4b595e23c72015e848205f986e2d714fd68bf
  Account ID:        0x128ea392292f8be6682543ee87e4b595e23c72015e848205f986e2d714fd68bf
  Public key (SS58): 5CV36Gk8ckF66wjQCdZshY7wzJyZ84MZso6DmTJWYcriCzoG
  SS58 Address:      5CV36Gk8ckF66wjQCdZshY7wzJyZ84MZso6DmTJWYcriCzoG
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have now the &lt;code&gt;ed25519&lt;/code&gt; public key &lt;code&gt;5CV36Gk8ckF66wjQCdZshY7wzJyZ84MZso6DmTJWYcriCzoG&lt;/code&gt; from the output.&lt;/p&gt;

&lt;p&gt;Make sure to save the output somewhere for later use from both commands.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Repeat this process for each node we would like to add to our network.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now to trust these accounts as &lt;strong&gt;validators&lt;/strong&gt; we need to create our &lt;a href="https://docs.substrate.io/build/chain-spec/"&gt;chain specification&lt;/a&gt;. Instead of creating one from scratch, we will modify the existing one.&lt;/p&gt;

&lt;p&gt;Generate the chain specification using the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;./target/debug/node-template build-spec --disable-default-bootnode --chain local &amp;gt; customSpec.json&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let's open up our chain specification and add our nodes as trusted participants for the network.&lt;/p&gt;

&lt;p&gt;We need to modify the &lt;code&gt;aura&lt;/code&gt; configuration to have our &lt;code&gt;sr25519&lt;/code&gt; keys to specify that these nodes are block producers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"aura"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"authorities"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"5DaS6dzomvqS3MpKcKgxz54GgEJje5Y11L1PHjyeMVniBrEM"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"5E4pr85gYVTc6kk4fQTa9keXaPh3Gnj5y9MWHQ4FN5ubxUv4"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to modify the &lt;code&gt;grandpa&lt;/code&gt; configuration to have our &lt;code&gt;ed25519&lt;/code&gt; keys to specify that these nodes have the authority to finalize blocks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"grandpa"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"authorities"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"5CV36Gk8ckF66wjQCdZshY7wzJyZ84MZso6DmTJWYcriCzoG"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"5CCr8YMJercfhvFaQ2z9pS3r6Pyf48mx9XFbuvFDamkfG524"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second value &lt;code&gt;1&lt;/code&gt; we precise for each node is the &lt;strong&gt;vote weight&lt;/strong&gt;. Each validator in this example has a weight of 1 vote.&lt;/p&gt;

&lt;h2&gt;
  
  
  Convert the chain specification to raw format
&lt;/h2&gt;

&lt;p&gt;The raw chain specification includes the same information as the unconverted specification. However, the raw chain specification also contains encoded storage keys that the node uses to reference the data in its local storage. Distributing a raw chain specification ensures that each node stores the data using the proper storage keys.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;./target/debug/node-template build-spec --chain=customSpec.json --raw --disable-default-bootnode &amp;gt; customSpecRaw.json&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When creating a private blockchain network, only one person should be generating and sharing the raw chain specification file so all nodes are running using the same wasm.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preparing to launch the private network
&lt;/h2&gt;

&lt;p&gt;To continue, verify the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You have generated or collected the account keys for at least two authority nodes/accounts.&lt;/li&gt;
&lt;li&gt;You have updated your custom chain specification to include the keys for block production (aura) and block finalization (grandpa).&lt;/li&gt;
&lt;li&gt;You have converted your custom chain specification to raw format and distributed the raw chain specification to the nodes participating in the private network.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Starting the first node
&lt;/h2&gt;

&lt;p&gt;We need to begin by starting the first node otherwise known as the &lt;strong&gt;bootnode&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Start the first node using the custom raw chain specification we generated earlier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./target/debug/node-template &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--base-path&lt;/span&gt; /tmp/node01 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--chain&lt;/span&gt; ./customSpecRaw.json &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--port&lt;/span&gt; 30333 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--ws-port&lt;/span&gt; 9945 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--rpc-port&lt;/span&gt; 9933 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--telemetry-url&lt;/span&gt; &lt;span class="s2"&gt;"wss://telemetry.polkadot.io/submit/ 0"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--validator&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--rpc-methods&lt;/span&gt; Unsafe &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--name&lt;/span&gt; MyNode01 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--password-interactive&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2023-01-09 23:06:50 Substrate Node    
2023-01-09 23:06:50 ✌️  version 4.0.0-dev-4ae6e26d2fc    
2023-01-09 23:06:50 ❤️  by Substrate DevHub &amp;lt;https://github.com/substrate-developer-hub&amp;gt;, 2017-2023    
2023-01-09 23:06:50 📋 Chain specification: iam Local Testnet    
2023-01-09 23:06:50 🏷  Node name: MyNode01    
2023-01-09 23:06:50 👤 Role: AUTHORITY    
2023-01-09 23:06:50 💾 Database: RocksDb at /tmp/node01/chains/local_testnet/db/full    
2023-01-09 23:06:50 ⛓  Native runtime: node-template-100 (node-template-1.tx1.au1)    
2023-01-09 23:06:51 🔨 Initializing Genesis block/state (state: 0x0e5a…205a, header-hash: 0xd977…d9a1)    
2023-01-09 23:06:51 👴 Loading GRANDPA authority set from genesis on what appears to be first startup.    
2023-01-09 23:06:52 Using default protocol ID "sup" because none is configured in the chain specs    
2023-01-09 23:06:52 🏷  Local node identity is: 12D3KooWDFcrrRui3J9JJGXX92dBtUqqFhZZzViDJy4QJD6DCJPG    
2023-01-09 23:06:52 💻 Operating system: macos    
2023-01-09 23:06:52 💻 CPU architecture: aarch64    
2023-01-09 23:06:52 📦 Highest known block at #0    
2023-01-09 23:06:52 〽️ Prometheus exporter started at 127.0.0.1:9615    
2023-01-09 23:06:52 Running JSON-RPC HTTP server: addr=127.0.0.1:9933, allowed origins=["http://localhost:*", "http://127.0.0.1:*", "https://localhost:*", "https://127.0.0.1:*", "https://polkadot.js.org"]    
2023-01-09 23:06:52 Running JSON-RPC WS server: addr=127.0.0.1:9945, allowed origins=["http://localhost:*", "http://127.0.0.1:*", "https://localhost:*", "https://127.0.0.1:*", "https://polkadot.js.org"]    
2023-01-09 23:06:58 💤 Idle (0 peers), best: #0 (0xd977…d9a1), finalized #0 (0xd977…d9a1), ⬇ 0 ⬆ 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some notable observations from the output: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the chain specification being used is the custom chain specification you created and specified using the &lt;code&gt;--chain&lt;/code&gt; command-line option.&lt;/li&gt;
&lt;li&gt;the node is an authority because you started the node using the &lt;code&gt;--validator&lt;/code&gt; command-line option.&lt;/li&gt;
&lt;li&gt;the genesis block being initialized with the block hash &lt;code&gt;(state: 0x0e5a…205a, header-hash: 0xd977…d9a1)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;the Local node identity for your node. In this example, the node identity is &lt;code&gt;12D3KooWDFcrrRui3J9JJGXX92dBtUqqFhZZzViDJy4QJD6DCJPG&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Insert keys in node keystore
&lt;/h3&gt;

&lt;p&gt;The node will not produce any blocks after starting the first node. We need to two types of keys to each of our nodes in the network.&lt;/p&gt;

&lt;p&gt;For each node:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add the &lt;code&gt;aura&lt;/code&gt; authority keys to enable &lt;a href="https://docs.substrate.io/reference/glossary/#author"&gt;block production&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Add the &lt;code&gt;grandpa&lt;/code&gt; authority keys to enable &lt;a href="https://docs.substrate.io/reference/glossary/#finality"&gt;block finalization&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Insert the &lt;code&gt;aura&lt;/code&gt; and &lt;code&gt;grandpa&lt;/code&gt; secret keys into the nodes keystore:&lt;/p&gt;

&lt;p&gt;Make sure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--base-path&lt;/code&gt; matches the same path used for starting the node. In this example, the path is &lt;code&gt;/tmp/node01&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--chain&lt;/code&gt; points to the raw chain specification file we generated earlier&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--suri&lt;/code&gt; value can be either the secret phrase or the secret seed created for each node
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./target/debug/node-template key insert &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--base-path&lt;/span&gt; /tmp/node01 &lt;span class="se"&gt;\ &lt;/span&gt;
  &lt;span class="nt"&gt;--chain&lt;/span&gt; customSpecRaw.json &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--scheme&lt;/span&gt; Sr25519 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--suri&lt;/span&gt; 0xd4883e547610a9543e1f68db1100833f3f57586b0e7a70437c84cb558ecd7cbe &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--password-interactive&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--key-type&lt;/span&gt; aura
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./target/debug/node-template key insert &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--base-path&lt;/span&gt; /tmp/node01 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--chain&lt;/span&gt; customSpecRaw.json &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--scheme&lt;/span&gt; Ed25519 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--suri&lt;/span&gt; 0xd4883e547610a9543e1f68db1100833f3f57586b0e7a70437c84cb558ecd7cbe &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--password-interactive&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--key-type&lt;/span&gt; gran
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify that the keys are in the keystore for &lt;code&gt;node01&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ls /tmp/node01/chains/local_testnet/keystore&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;6175726142e88babfc903a7f3c12e576f52288144487f019ff9d2605df0f558c617a6909
6772616e128ea392292f8be6682543ee87e4b595e23c72015e848205f986e2d714fd68bf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now restart the node.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start the second node
&lt;/h2&gt;

&lt;p&gt;Run the following command to start the second node using the same raw chain specification:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./target/debug/node-template &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--base-path&lt;/span&gt; /tmp/node02 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--chain&lt;/span&gt; ./customSpecRaw.json &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--port&lt;/span&gt; 30334 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--ws-port&lt;/span&gt; 9946 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--rpc-port&lt;/span&gt; 9934 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--telemetry-url&lt;/span&gt; &lt;span class="s2"&gt;"wss://telemetry.polkadot.io/submit/ 0"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--validator&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--rpc-methods&lt;/span&gt; Unsafe &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--name&lt;/span&gt; MyNode02 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--bootnodes&lt;/span&gt; /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWDFcrrRui3J9JJGXX92dBtUqqFhZZzViDJy4QJD6DCJPG &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--password-interactive&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Make sure to replace the &lt;code&gt;--bootnodes&lt;/code&gt; node identity with the one you have running&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Insert the secret keys like we did with the first node but this time in &lt;code&gt;/tmp/node02&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Follow the same steps here to configure the second node&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Finally, Substrate nodes require a restart after inserting a &lt;code&gt;grandpa&lt;/code&gt; key, so you must shut down and restart nodes before you see blocks being finalized.&lt;br&gt;
Restart both nodes in the right order and you should also see that each node has one peer &lt;code&gt;(1 peers)&lt;/code&gt;, and they have produced a block proposal &lt;code&gt;(best: #2 (0xe111…c084))&lt;/code&gt;. After a few seconds, you should see new blocks being finalized on both nodes &lt;code&gt;finalized #1 (0x45a4…52d1)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Congratulations, you made it to the end!&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>rust</category>
    </item>
  </channel>
</rss>
