6

How to connect an ethereum node (eth, geht, pyeth) to a random testnet and what do the network IDs stand for. Are there network IDs I should not use because they are maybe used elsewhere or reserved?

  • Can you clarify what is meant by "random"? Would "arbitrary" be a better descriptor of what you're trying to achieve? – Taylor Gerring Jan 21 '16 at 13:28
8

For Geth you can connect to the public testnet (Morden) via:

geth --testnet

For other clients and for a full explanation plese refer to this wiki page: Ethereum wiki / Morden

If you don't want to use the main public testnet you could use another public testnet, for that you have to specify at least these parameters:

geth --networkid=12345 --genesis genesis.json

So you have to know the right networkid and you have to have the right genesis block to load. Nodes will be discovered based on network ID, also you can add other enodes via the --bootnodes geth argument, more infos here.

If you connect to testnets that use the same genesis block like the consensys one then you just need to specify the --bootnodes flag with the right enode.

If your goal is to create a private chain for testing, instead, then I suggest to follow this guide (with Geth again).

When you create your private you can specify the "alloc" parameter on your genesis json file to allocate almost infinite ethers to your account so you don't have to mine constantly. You can also use a mine script like this to pass as parameter in your geth call like so:

geth ...other..parameters... js geth_mine.js

to mine only when new transactions appear. Also, you will usually call --nodiscover do disable nodes discovery on your private net, then, to make multiple geth instances connect to teach other, you need to specify the peers via --bootnodes or via admin.addPeer() in the geth_mine.js script, you can find your enodes by adding console.log(admin.nodeInfo.enode) to the script or by loading the geth console by with:

geth ...other..parameters... console

then

> miner.stop()
> admin.nodeInfo.enode

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.