infrablockchain-docs
en
en
  • InfraBlockchain
    • Learn
      • Architecture
        • Architecture
        • Network Participants
        • Parachain
          • System Parachains
      • Protocol
        • System Token
        • Transaction Fee
        • Proof of Transaction
      • Substrate
        • Learn
          • Basic
            • Cryptography
            • Blockchain Basics
            • Consensus
            • Networks and Nodes
            • Blockchain Transaction
            • Transaction Life Cycle
            • Offchain Operations
            • Light Client
            • Rust for Substrate
            • Introduction to Library
            • Architecture and Rust Libraries
            • File Architecture
            • Accounts, Addresses, and Keys
            • Transaction Format
            • Blockchain Randomness
          • FRAME
            • FRAME Pallets
            • FRAME Macros
            • Custom Pallets
            • Pallet Coupling
            • Origin
            • Events and Erros
            • Runtime Storage
            • State Transitions and Storage
            • SCALE Encoding
            • Weight and Fee
            • Runtime API
            • Runtime Development
          • Account
          • Address Format
          • Glossary
          • CLI
            • Archive
            • Memory Profiler
            • Node Template
            • sidecar
            • srtool
            • Subkey
            • subxt
            • try-runtime
            • tx-wrapper
          • Runtime Development
            • Basics
              • Configure Genesis State
              • Configure Runtime Constants
              • Customize a Chain Spec
              • Import a Pallet
              • Use Helper Function
            • Consensus Model
              • PoW
              • Create a Hybrid Node
            • Offchain Worker
              • Request Offchain HTTP
              • Offchain Indexing
              • Offchain Local Storage
            • Pallet Design
              • Create a Storage Structure
              • Implement Lockable Currency
              • Incorporate Randomness
              • Loose Coupling
              • Tight Coupling
            • Parachain Development
              • Add HRMP Channel
              • Add Paranodes
              • Connect to a Local Relay Chain
              • Convert a Solo Chain
              • Prepare to Launch
              • Select Collator
              • Upgrade a Parachain
            • Storage Migration
              • Basics
              • Trigger Migration
            • Test
              • Basics
              • Test a Transfer Transaction
            • Tools
              • Create a TxWrapper
              • Use Sidecar
              • try-runtime
              • Verify WASM
            • Weigths
              • Benchmark
              • Calculate Fees
              • Use Conditional Weights
              • Use Custom Weights
        • Build
          • Decide What to Build
          • Build Process
          • Determinisitc Runtime
          • Chain Spec
          • Genesis Configuration
          • Application Development
          • RPC
          • Troubleshoot Your Code
        • Tutorials
          • Install
            • Developer Tools
            • Linux
            • macOS
            • Rust Toolchain
            • Issues
            • Windows
          • Quick Start
            • Explore the Code
            • Modify Runtime
            • Start a Node
            • Substrate Basics
          • Build a Blockchain
            • Add Trusted Nodes
            • Authorize Specific Nodes
            • Build a Local Blockchain
            • Simulate Network
            • Upgrade a Running Network
          • Build Application Logic
            • Add a Pallet
            • Add Offchasin Workers
            • Publish Custom Pallets
            • Specify Origin for a Call
            • Use Macros in a Custom Pallet
          • Integrate with Tools
            • Access EVM Accounts
            • EVM Integration
            • Explore Sidecar Endpoints
            • Integrate a Light Client Node
          • Smart Contracts
            • Strategy
            • Build a Token Contract
            • Develop a Smart Contract
            • Prepare Your First Contract
            • Troubleshoot Smart Contracts
            • Use Maps for Storing Values
      • XCM
        • XCM
        • XCM Format
    • Service Chains
      • InfraDID
      • InfraEVM
      • URAuth(Universal Resource Auth)
    • DevOps
      • Build
      • Deploy
      • Monitoring
      • Runtime Upgrade
    • Tutorials
      • Basic
        • How to Interact with System Token
        • How To Pay Transaction Fee
        • How To Vote with TaaV
        • Hot to Get Validator Reward
      • Build
        • Build InfraRelayChain
        • Build Parachain
        • Open Message Passing Channels
        • Transfer Assets with XCM
      • Test
        • Benchmark
        • Check Runtime
        • Debug
        • Simulate Parachains
        • Unit Testing
      • Service Chains
        • Play with InfraDID
          • Build
          • Add Keys
          • Add Service Endpoint
          • Create InfraDID
        • Play with InfraEVM
          • Build
          • Deposit and Withdraw Token
          • Deploy ERC20 Contract
          • Deploy ERC721 Contract
          • Deploy ERC1155 Contract
  • Newnal Data Market
Powered by GitBook
On this page
  • Before you begin
  • Build the node template
  • View information for the node
  • Start the blockchain
  • Connect to the node
  • Stop the node
  1. InfraBlockchain
  2. Learn
  3. Substrate
  4. Tutorials
  5. Quick Start

Start a Node

Started your first Substrate node from a template.

PreviousModify RuntimeNextSubstrate Basics

Last updated 1 year ago

All of the Substrate tutorials and how-to guides require you to build and run a Substrate node in your development environment. To help you set up a working environment quickly, the maintains templates for you to use. For example, the is a snapshot of the main Substrate node-template binary that includes a core set of features to get you started.

After you start the node, you can connect to it using a web browser and a simple application that allows you to look up a balance for a predefined account.

Before you begin

Before you begin, verify the following:

  • You have an internet connection and access to an interactive shell terminal on your local computer.

  • You are generally familiar with software development and using command-line interfaces.

  • You have the Rust compiler and toolchain installed.

    You can check whether you have Rust installed by running the rustup show command. If Rust is installed, this command displays version information for the toolchain and compiler. If Rust is not installed, the command doesn't return any output. For information about installing Rust, see .

Build the node template

  1. Clone the node template repository by running the following command:

    git clone https://github.com/substrate-developer-hub/substrate-node-template

    This command clones the main branch.

    Optionally, you can use the --branch command-line option and a to specify a version of Polkadot you want the node to be compatible with.

  2. Change to the root of the cloned directory:

    cd substrate-node-template
  3. Create a new branch to save your work by running a command similar to the following:

    git switch -c my-learning-branch-yyyy-mm-dd

    You can name the branch using any identifying information you choose. In most cases, you should include information about the year-month-day you cloned the branch in the name. For example:

    git switch -c my-learning-branch-2023-03-31
  4. Compile the node template:

    cargo build --package node-template --release

    The first time you compile the node, it can take some time to complete. When compiling is complete, you should see a line like this:

    Finished release [optimized] target(s) in 11m 23s

View information for the node

  1. Verify that your node is ready to use and see information about the command-line options available by running the following command:

    ./target/release/node-template --help

    The usage information displays the command-line options you can use to:

    • start the node

    • work with accounts and keys

    • modify node operations

  2. View account information for the predefined Alice development account by running the following command:

    ./target/release/node-template key inspect //Alice

    The command displays the following account and address information:

    Secret Key URI `//Alice` is account:
    Network ID:        substrate
    Secret seed:       0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a
    Public key (hex):  0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
    Account ID:        0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
    Public key (SS58): 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
    SS58 Address:      5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY

Start the blockchain

  1. Start the node in development mode by running the following command:

    ./target/release/node-template --dev

    In development mode, the chain doesn't require any peer computers to finalize blocks. As the node starts, the terminal displays output about the operations performed. If you see messages that blocks are being proposed and finalized, you have a running node.

    ... Idle (0 peers), best: #3 (0xcc78…5cb1), finalized #1 ...
    ... Starting consensus session on top of parent ...
    ... Prepared block for proposing at 4 (0 ms) ...

Connect to the node

  • Take an account address as input.

  • Look up the account balance using an onClick event.

  • Display the balance for the account as output.

To connect to the node and check an account balance:

  1. Open the index.html file in a web browser.

  2. Copy and paste the SS58 Address for the Alice account in the input field, then click Get Balance.

Stop the node

  1. Go to the terminal that displays blockchain operations.

  2. Stop the local blockchain and clear all state by pressing the control-c key combination.

Predefined development accounts like Alice and Bob are configured in a chain specification file. You'll learn more about node template files in and more specifically about the chain specification file in . For now, it's enough to be aware that development accounts exist to enable testing of simple transactions like balance transfers.

Now that your node is running, you can connect to it to check the balance of the predefined Alice account. For this simple application, you can create one index.html HTML file that uses JavaScript and the to interact with the blockchain.

For example, this sample demonstrates how to use JavaScript, the Polkadot-JS API, and HTML to do the following:

Copy and paste the for the Quick start: Get Balance application into a new file in your code editor and save the file on your local computer.

Substrate Developer Hub
substrate-node-template
Install
tag
Explore the code
Chain specification
Polkadot-JS API
index.html
sample code