Reputation: 3219
I am creating a private Network (Ethereum). I wrote out the genesis.json file (code below), I then initialized it without error, but when I try to connect to it, a new line is created (implying an additional command should be specified). When I press enter, geth simply connects to the main network. How do I get geth to connect to the private network?
note: you can immediately tell geth connects to the main network because my chain's ID is 15 and it shows a connection to 1.
genesis.json:
{
"difficulty" : "0x20000",
"extraData" : "",
"gasLimit" : "0x8000000",
"alloc": {},
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
}
}
Command Line:
Ryan-Cocuzzos-Laptop:BlockDev Ryan$ geth init ./genesis.json --datadir mychaindata
WARN [01-05|12:12:00] No etherbase set and no accounts found as default
INFO [01-05|12:12:00] Allocated cache and file handles database=/Users/Ryan/Desktop/BlockDev/mychaindata/geth/chaindata cache=16 handles=16
INFO [01-05|12:12:00] Writing custom genesis block
INFO [01-05|12:12:00] Successfully wrote genesis state database=chaindata hash=0613eb…9a64e7
INFO [01-05|12:12:00] Allocated cache and file handles database=/Users/Ryan/Desktop/BlockDev/mychaindata/geth/lightchaindata cache=16 handles=16
INFO [01-05|12:12:00] Writing custom genesis block
INFO [01-05|12:12:00] Successfully wrote genesis state database=lightchaindata hash=0613eb…9a64e7
Ryan-Cocuzzos-Laptop:BlockDev Ryan$ geth --datadir .\mychaindata\
>
WARN [01-05|12:13:37] No etherbase set and no accounts found as default
INFO [01-05|12:13:37] Starting peer-to-peer node instance=Geth/v1.7.3-stable/darwin-amd64/go1.9.2
INFO [01-05|12:13:37] Allocated cache and file handles database=/Users/Ryan/Desktop/BlockDev/.mychaindata/geth/chaindata cache=128 handles=1024
INFO [01-05|12:13:37] Writing default main-net genesis block
INFO [01-05|12:13:37] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Engine: ethash}"
INFO [01-05|12:13:37] Disk storage enabled for ethash caches dir=/Users/Ryan/Desktop/BlockDev/.mychaindata/geth/ethash count=3
INFO [01-05|12:13:37] Disk storage enabled for ethash DAGs dir=/Users/Ryan/.ethash count=2
INFO [01-05|12:13:37] Initialising Ethereum protocol versions="[63 62]" network=1
INFO [01-05|12:13:37] Loaded most recent local header number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [01-05|12:13:37] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [01-05|12:13:37] Loaded most recent local fast block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [01-05|12:13:37] Regenerated local transaction journal transactions=0 accounts=0
INFO [01-05|12:13:37] Starting P2P networking
ADDITIONAL INFO: I am running MacOS Sierra (10.12.3) I am using Terminal (2.7.1)
Upvotes: 0
Views: 1653
Reputation: 478
You are missing --networkid
and other import parameters like port etc.
Use below command for connecting to your network.
geth --networkid 15 --datadir .\mychaindata
Additional parameters for geth
are below
geth --networkid <chainId>
--mine
--datadir <datadir>
--nodiscover
--rpc --rpcport "8545"
--port "30303"
--rpccorsdomain "*"
--nat "any"
--rpcapi eth,web3,personal,net
--unlock 0
--password <password file>
--ipcpath <path to .ipc file>
Upvotes: 0
Reputation: 10991
You're missing --networkid
when starting geth
.
geth --networkid 15 --datadir mychaindata
Upvotes: 1