• NEC Website
  • GitHub
  • Discord Community

Quick Start

  • Get Started

Staking

  • Quick Start
  • Overview
  • Stake on NCOG
  • Run NCOGEarthChain
  • Run Validator Node
  • Running Testnet
  • Operating a private network (fakenet)
  • Running the demo
  • Run a Read-only node
  • Testnet Faucet
  • Run a Full node
  • Run a Testnet read node

API

  • Public API End Points
  • Getting Started
  • Installation
  • GraphQL Schema Basics
  • Schema Structure
  • Implementation Details and Notes

Tutorials

  • Create a ERC721 Contract
  • Deploy a Smart Contract
  • Verify a Deployed Smart Contract
  • Setup MetaMask Wallet
  • Import NFT
  • Create a Local Test Network

Technology

  • Overview
  • Forest Protocal
  • Tolerance to Byzantine Fault (BFT)
  • Proof of Stake
  • Transaction Fees
  • FAQ

Best Practices

  • MANAGE NEC ASSETS WITH LEDGER NANO S
  • How to Navigate NCOG NEC
  • How to Check Your Account Balance
  • How to Receive NCOG Assets
  • How to Send NCOG Assets
  • Leager FAQ
  • Home
  • Docs
  • Tutorials
  • Create a Local Test Network

Create a Local Test Network

Table of Contents
  • Building the source
  • Running ncogearthchain
  • Configuration
  • Dev
  • Operating a private network (fakenet)
  • Running the demo

Building the source #

Building ncogearthchain requires both a Go (version 1.14 or later) and a C compiler. You can install them using your favourite package manager. Once the dependencies are installed, run

make ncogearthchain

The build output is build/ncogearthchain executable.

Running ncogearthchain #

Going through all the possible command line flags is out of scope here, but we’ve enumerated a few common parameter combos to get you up to speed quickly on how you can run your own ncogearthchain instance.

Launching a network

Launching ncogearthchain for a network:

$ ncogearthchain --genesis /path/to/genesis.g

Configuration #

As an alternative to passing the numerous flags to the ncogearthchain binary, you can also pass a configuration file via:

$ ncogearthchain --config /path/to/your_config.toml

To get an idea how the file should look like you can use the dumpconfig subcommand to export your existing configuration:

$ ncogearthchain --your-favourite-flags dumpconfig

Validator
New validator private key may be created with ncogearthchain validator new command.

To launch a validator, you have to use --validator.id and --validator.pubkey flags to enable events emitter.

$ ncogearthchain –nousb –validator.id YOUR_ID –validator.pubkey 0xYOUR_PUBKEY
ncogearthchain will prompt you for a password to decrypt your validator private key. Optionally, you can specify password with a file using –validator.password flag.

Participation in discovery
Optionally you can specify your public IP to straighten connectivity of the network. Ensure your TCP/UDP p2p port (5050 by default) isn’t blocked by your firewall.

$ ncogearthchain --nat extip:1.2.3.4

Dev #

Running testnet
The network is specified only by its genesis file, so running a testnet node is equivalent to using a testnet genesis file instead of a mainnet genesis file:

$ ncogearthchain --genesis /path/to/testnet.g # launch node

It may be convenient to use a separate datadir for your testnet node to avoid collisions with other networks:

$ ncogearthchain --genesis /path/to/testnet.g --datadir /path/to/datadir # launch node
$ ncogearthchain --datadir /path/to/datadir account new # create new account
$ ncogearthchain --datadir /path/to/datadir attach # attach to IPC

Testing
Forest has extensive unit-testing. Use the Go tool to run tests:

go test ./...

If everything goes well, it should output something along these lines:

ok  	github.com/Ncog-Earth-Chain/go-ncogearthchain/app	0.033s
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/cmd/cmdtest	[no test files]
ok  	github.com/Ncog-Earth-Chain/go-ncogearthchain/cmd/ncogearthchain	13.890s
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/cmd/ncogearthchain/metrics	[no test files]
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/cmd/ncogearthchain/tracing	[no test files]
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/crypto	[no test files]
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/debug	[no test files]
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/ethapi	[no test files]
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/eventcheck	[no test files]
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/eventcheck/basiccheck	[no test files]
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/eventcheck/gaspowercheck	[no test files]
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/eventcheck/heavycheck	[no test files]
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/eventcheck/parentscheck	[no test files]
ok  	github.com/Ncog-Earth-Chain/go-ncogearthchain/evmcore	6.322s
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/gossip	[no test files]
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/gossip/emitter	[no test files]
ok  	github.com/Ncog-Earth-Chain/go-ncogearthchain/gossip/filters	1.250s
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/gossip/gasprice	[no test files]
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/gossip/occuredtxs	[no test files]
?   	github.com/Ncog-Earth-Chain/go-ncogearthchain/gossip/piecefunc	[no test files]
ok  	github.com/Ncog-Earth-Chain/go-ncogearthchain/integration	21.640s

Also it is tested with fuzzing.

Operating a private network (fakenet) #

Fakenet is a private network optimized for your private testing. It’ll generate a genesis containing N validators with equal stakes. To launch a validator in this network, all you need to do is specify a validator ID you’re willing to launch.

Pay attention that validator’s private keys are deterministically generated in this network, so you must use it only for private testing.

Maintaining your own private network is more involved as a lot of configurations taken for granted in the official networks need to be manually set up.

To run the fakenet with just one validator (which will work practically as a PoA blockchain), use:

$ ncogearthchain --fakenet 1/1

To run the fakenet with 5 validators, run the command for each validator:

$ ncogearthchain --fakenet 1/5 # first node, use 2/5 for second node

If you have to launch a non-validator node in fakenet, use 0 as ID:

$ ncogearthchain --fakenet 0/5

After that, you have to connect your nodes. Either connect them statically or specify a bootnode:

$ ncogearthchain --fakenet 1/5 --bootnodes "enode://[email protected]:5050"

Running the demo #

For the testing purposes, the full demo may be launched using:

cd demo/
./start.sh # start the Ncogearthchain processes
./stop.sh # stop the demo
./clean.sh # erase the chain data
What are your Feelings
Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Still stuck? How can we help?

How can we help?

Updated on November 24, 2023
Import NFT

Powered by BetterDocs

Table of Contents
  • Building the source
  • Running ncogearthchain
  • Configuration
  • Dev
  • Operating a private network (fakenet)
  • Running the demo
© 2023. NCOG Earth Chain. All Rights Reserved.