Giter Club home page Giter Club logo

building-a-private-blockchain-using-ethereum's Introduction

Building-a-Private-Blockchain-using-Ethereum

Geth Installation for Windows

https://geth.ethereum.org/

Note: Tick all the boxes during installation.

Invoking Installed Geth in cmd

geth console

Creating a new Folder Ethereum

mkdir go-ethereum
cd go-ethereum
mkdir node1
mkdir node2
mkdir bnode

Creation of New Accounts

Account 1

cd node1
geth --datadir "./data" account new

Account 2

cd node2
geth --datadir "./data" account new

Create Info.txt

Primarily used for storing info such as Account ID, passwords, and enode.

Verifing the ChainID

https://chainlist.org/

Note: ChainId must be unique or else our Private Blockchain could merge with Public Blockchain Network.

Genesis Block Code

//Genesis_File

{
  "config": {
    "chainId": { CHAIN_ID },
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "berlinBlock": 0,
    "clique": {
      "period": 5,
      "epoch": 30000
    }
  },
  "difficulty": "1",
  "gasLimit": "8000000",
  "extradata": "0x0000000000000000000000000000000000000000000000000000000000000000{ INITIAL_SIGNER_ADDRESS }0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "alloc": {
    "{ FIRST_NODE_ADDRESS }": { "balance": "{ ETHER_AMOUNT }" },
    "{ SECOND_NODE_ADDRESS }": { "balance": "{ EHTER_AMOUNT }" }
  }
}

Initializing Accounts with Genesis File

geth --datadir ./data init ../genesis.json

Initializing of BootNode

cd bnode

Generation of BootKey

bootnode -genkey boot.key
bootnode -nodekey boot.key -verbosity 7 -addr "127.0.0.1:30302"

Note: Copy and save it to info.txt enode value from cmd.

Initializing Nodes in the Blockchain

Signer Node

geth --datadir "./data"  --port 30304 --bootnodes enode://{ YOUR_VALUE } --authrpc.port 8547 --ipcdisable --allow-insecure-unlock  --http --http.corsdomain="https://remix.ethereum.org" --http.api web3,eth,debug,personal,net --networkid { NETWORK_ID } --unlock { ADDRESS_NODE1 } --password { PASSWORD_FILE_NAME_EXTENSION }  --mine --miner.etherbase= { SIGNER_ADDRESS }

Note: Store the password in Ethereum\node1\data\password.txt

Sender Node

geth --datadir "./data"  --port 30306 --bootnodes enode://{ YOUR_VALUE }  -authrpc.port 8546 --networkid { NETWORK_ID } --unlock { ADDRESS_NODE2 } --password { PASSWORD_FILE_WITH_EXTENSION }

Note: Store the password in Ethereum\node2\data\password.txt

Remix

https://remix.ethereum.org/

Conduting a Simple Peer-to-peer Transfer

//SPDX-License-Identifier:MIT

pragma solidity ^0.8.19;

contract New{
	string name;

	function setName(string memory _name)public {
		name=_name;
	} 
	function getName()public view returns(string memory){
		return name;
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.