windows下搭建cpp-ethereum私有链

 1.在编译出来的aleth.exe目录下创建一个创世块文件genesis.json:

{ 
 	"sealEngine": "Ethash", 
 	"params": { 
 		"accountStartNonce": "0x00", 
 		"maximumExtraDataSize": "0x20", 
 		"homesteadForkBlock": "0x00", 
 		"EIP150ForkBlock": "0x00", 
 		"EIP158ForkBlock": "0x00", 
 		"byzantiumForkBlock": "0x00", 
 		"constantinopleForkBlock": "0x00", 
 		"minGasLimit": "0x1388", 
 		"maxGasLimit": "7fffffffffffffff", 
 		"tieBreakingGas": false, 
 		"gasLimitBoundDivisor": "0x0400", 
 		"minimumDifficulty": "0x020000", 
 		"difficultyBoundDivisor": "0x0800", 
 		"durationLimit": "0x0d", 
 		"blockReward": "0x4563918244F40000", 
 		"networkID" : "0x454", 
 		"chainID": "0x01", 
 		"allowFutureBlocks" : true 
 	}, 
 	"genesis": { 
 		"nonce": "0x0000000000000042", 
 		"difficulty": "0x400000000", 
 		"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 
 		"author": "0x0000000000000000000000000000000000000000", 
 		"timestamp": "0x00", 
 		"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 
 		"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 
 		"gasLimit": "0x1388" 
 	}, 
 	"accounts": { 
 		"0000000000000000000000000000000000000001": { "precompiled": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } }, 
 		"0000000000000000000000000000000000000002": { "precompiled": { "name": "sha256", "linear": { "base": 60, "word": 12 } } }, 
 		"0000000000000000000000000000000000000003": { "precompiled": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } }, 
 		"0000000000000000000000000000000000000004": { "precompiled": { "name": "identity", "linear": { "base": 15, "word": 3 } } }, 
 		"0000000000000000000000000000000000000005": { "precompiled": { "name": "modexp" } }, 
 		"0000000000000000000000000000000000000006": { "precompiled": { "name": "alt_bn128_G1_add", "linear": { "base": 500, "word": 0 } } }, 
 		"0000000000000000000000000000000000000007": { "precompiled": { "name": "alt_bn128_G1_mul", "linear": { "base": 40000, "word": 0 } } }, 
 		"0000000000000000000000000000000000000008": { "precompiled": { "name": "alt_bn128_pairing_product" } } 
 	} 
 } 

2.打开cmd,进入aleth.exe目录,输入命令行开始挖矿:

aleth --config genesis.json -m on -v 5 --network-id 1108 --ipc --listen 30307 --port 30307 --db-path blockchain --private "mynet"

3.打开ethconsole进行连接,得到一个web3对象,然后就可以通过web3这个对象来操作了,关于web3的api可以参考http://web3js.readthedocs.io/en/1.0/index.html

NAME:
   aleth 1.5.0.dev0+commit.fbf30b71.dirty
USAGE:
   aleth [options]

WALLET USAGE:
   account list                                List all keys available in wallet
   account new                                 Create a new key and add it to wallet
   account update [|
, ... ] Decrypt and re-encrypt keys account import [||] Import keys from given source and place in wallet wallet import Import a presale wallet CLIENT MODE (default): --mainnet Use the main network protocol --ropsten Use the Ropsten testnet --private Use a private chain --test Testing mode; disable PoW and provide test rpc interface --config Configure specialised blockchain using given JSON information -o [ --mode ] Start a full node or a peer node (default: full) --ipc Enable IPC server (default: on) --ipcpath Set .ipc socket path (default: data directory) --no-ipc Disable IPC server --admin Specify admin session key for JSON-RPC (default: auto-generated and printed at start-up) -K [ --kill ] Kill the blockchain first -R [ --rebuild ] Rebuild the blockchain from the existing database --rescue Attempt to rescue a corrupt database --import-presale Import a pre-sale key; you'll need to specify the password to this key -s [ --import-secret ] Import a secret key into the key store -S [ --import-session-secret ] Import a secret session into the key store --master Give the master password for the key store; use --master "" to show a prompt --password Give a password for a private key CLIENT TRANSACTING: --ask Set the minimum ask gas price under which no transaction will be mined (default: 20000000000) --bid Set the bid gas price to pay for transactions (default: 20000000000) --unsafe-transactions Allow all transactions to proceed without verification; EXTREMELY UNSAFE CLIENT MINING: -a [ --address ] Set the author (mining payout) address (default: auto) -m [ --mining ] Enable mining; optionally for a specified number of blocks (default: off) --extra-data arg Set extra data for the sealed blocks CLIENT NETWORKING: -b [ --bootstrap ] Connect to the default Ethereum peer servers (default unless --no-discovery used) --no-bootstrap Do not connect to the default Ethereum peer servers (default only when --no-discovery is used) -x [ --peers ] Attempt to connect to a given number of peers (default: 11) --peer-stretch Give the accepted connection multiplier (default: 7) --public-ip Force advertised public IP to the given IP (default: auto) --listen-ip (:) Listen on the given IP for incoming connections (default: 0.0.0.0) --listen Listen on the given port for incoming connections (default: 30303) -r [ --remote ] (:) Connect to the given remote host (default: none) --port Connect to the given remote port (default: 30303) --network-id Only connect to other hosts with this network id --peerset Space delimited list of peers; element format: type:publickey@ipAddress[:port] Types: default Attempt connection when no other peers are available and pinning is disabled required Keep connected at all times --no-discovery Disable node discovery; implies --no-bootstrap --pin Only accept or connect to trusted peers BENCHMARKING MODE: -M,--benchmark Benchmark for mining and exit --benchmark-warmup Set the duration of warmup for the benchmark tests (default: 3) --benchmark-trial Set the duration for each trial for the benchmark tests (default: 3) --benchmark-trials Set the number of trials for the benchmark tests (default: 5) MINING CONFIGURATION: -C,--cpu When mining, use the CPU -t, --mining-threads Limit number of CPU/GPU miners to n (default: use everything available on selected platform) --current-block Let the miner know the current block number at configuration time. Will help determine DAG size and required GPU memory --disable-submit-hashrate When mining, don't submit hashrate to node IMPORT/EXPORT MODES: -I [ --import ] Import blocks from file -E [ --export ] Export blocks to file --from Export only from block n; n may be a decimal, a '0x' prefixed hash, or 'latest' --to Export only to block n (inclusive); n may be a decimal, a '0x' prefixed hash, or 'latest' --only Equivalent to --export-from n --export-to n --format Set export format --dont-check Prevent checking some block aspects. Faster importing, but to apply only when the data is known to be valid --download-snapshot Download Parity Warp Sync snapshot data to the specified path --import-snapshot Import blockchain and state data from the Parity Warp Sync snapshot VM OPTIONS: --vm | (=legacy) Select VM implementation. Available options are: interpreter, legacy. --evmc

 

你可能感兴趣的:(windows下搭建cpp-ethereum私有链)