OJA Coin
  • OJA Coin Intro
  • Guides
    • ☕Get Started
    • 🛣️Roadmap
    • 📃Whitepaper
    • 🤝Coinomics
    • 🔗Official Links
    • 💹Buy OJA Coin
    • ✨OJX Node Installation
  • PRODUCTS
    • ⚡OJA Blockchain (OJX)
    • 👨‍💻OJA Wallet
    • 🏆OJA Rewards
    • 📈OJA Trading / Exchange
    • 🪙OJA Payment
  • OJA SMART CHAIN (OJX20)
    • ☕Get Started (OJX20)
    • 🌟OJA Coin Smart Chain
      • Concepts
        • Consensus
        • Genesis File
      • Source Code
      • Main Network Explorer
      • Test Network Explorer
      • OJX20 Wallet
    • 💻Developers
      • General
        • Create Wallet
        • Smart Contract
        • Remix
        • Web3JS
        • Truffle
      • Deploy
        • Remix
        • Truffle
        • HardHat
      • Tools
      • BRC20 Tokens
        • Introduction
        • Issue Token
      • Blockchain Details
        • OJX Chain Fullnode
        • RPC
      • Tutorial
        • Deploy NFT
        • Local OJX Network
    • 🚰OJX Faucet
    • ❔FAQ
      • OJA Coin Smart Chain FAQ
        • General
          • Info
          • OJA Coin Smart Chain (OJX20)
          • Ecosystem
        • Token
          • Intro
      • Contributing
  • OJA COIN MINING
    • ☕Get Started
    • 💸Sole Mining (CPU)
    • 💰Masternode Mining
    • 🖥️GPU Mining
  • Others
    • OJA Brand Assets
    • Support
  • Terms
    • Privacy Policy
    • Terms and User Agreement
Powered by GitBook
On this page
  • Setting up your OJX Node(s)
  • Useful geth commands
  • Connect to other nodes on your network
  1. OJA SMART CHAIN (OJX20)
  2. Developers
  3. Tutorial

Local OJX Network

PreviousDeploy NFTNextFAQ

Last updated 3 years ago

See also :

Setting up your OJX Node(s)

1. Prereq : Install Geth

Review the guide

2. Prereq : create /projects

Create a /projects symbolic link (Note: This step is simply so "/projects" can be used in all other commands, instead you could use full paths, or set an env var)

$ mkdir <my projects folder>
$ sudo ln -s <my projects folder> /projects

3. Create local_ethereum_blockchain folder

$ mkdir /projects/local_ethereum_blockchain

4. Create the genesis block config

Create this file : /projects/local_ethereum_blockchain/genesis.json

With the following contents :

{
     "config": {
       "chainId": 1000,
       "homesteadBlock": 0,
       "eip155Block": 0,
       "eip158Block": 0
                },
     "nonce": "0x0000000000000061",
     "timestamp": "0x0",
     "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
     "gasLimit": "0x8000000",
     "difficulty": "0x100",
     "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
     "coinbase": "0x3333333333333333333333333333333333333333",
     "alloc": {}
}

5. Initialise an Ethereum node

$ geth --datadir /projects/local_ethereum_blockchain/node1 init /projects/local_ethereum_blockchain/genesis.json

6. Start that Ethereum node

$ geth --datadir /projects/local_ethereum_blockchain/node1 --networkid 1000 console

7. Initialise another Ethereum node

$ geth --datadir /projects/local_ethereum_blockchain/node-2 init /projects/local_ethereum_blockchain/genesis.json

8. Start the 2nd Ethereum node

$ geth --datadir /projects/local_ethereum_blockchain/node-2 --port 30304 --nodiscover --networkid 1000 console

9. Connect one node to the other

In one geth console :

> admin.nodeInfo.enode

In the other console :

> admin.addPeer( <the enode value from the first console> )

Useful geth commands

Node info

> admin.nodeInfo

Peers

Show peers

> admin.peers

How many peers ?

> admin.peers.length

Create an account

You need an account to do be able to do things like mining

> personal.newAccount()

And make sure your remember/save the password!

Unlock account

Neccessary before some actions

> personal.unlockAccount( eth.accounts[0] )

Start mining

> miner.start(1)

The first block may take a while to mine, allow a few minutes

Stop mining

> miner.stop()

Current block number

> eth.blockNumber

Details of current block

> eth.getBlock( eth.blockNumber )

Which node minded the last block

> eth.getBlock(eth.blockNumber).miner

Account balance, in ether

> web3.fromWei(eth.getBalance(eth.accounts[0]))

Transfer ether between accounts

First get the account numbers by doing

> eth.accounts

Then unlock the account you are sending from

> personal.unlockAccount( <from account> )

eg.

> personal.unlockAccount(eth.accounts[0])

Finally transfer 1 ether

> eth.sendTransaction({from: "<from account>", to: "<to account>", value: web3.toWei(1, "ether")})

Exit

> exit

(This will also stop the node from running if it was started using $ geth console (as opposed to $ geth attach))

Connect to other nodes on your network

  1. Get the IP of the node : $ ifconfig|grep netmask|awk '{print $2}'

  2. Get the enode of the node : > admin.nodeInfo.enode

  3. REPLACE [::] in the enode string with the [<ip address>]

  4. On your console > admin.addPeer(< the enode string with the ip address in it>)

()

💻
https://github.com/ethereum/go-ethereum/wiki/Private-network
here
info about the genesis file