1-下载以太坊源码: download ethereum: https://github.com/ethereum/Go-ethereum/tree/release/1.3.3
2- 重命名代码:rename folder to go-neochain
3- 重命名相关文件和文件夹 rename files and folders:
- replace ethereum with neochain in files and folders filenames - replace eth with vch in files and folders filenames
4- replace occurences of ethereum in the code (using text replace software like grepWin): 重命名ethereum 代码中的所有ethereum字符,并替换成neochain,具体替换项目如下:
- repalce github.com/ethereum/go-ethereum with github.com/neochain/go-neochain - repalce ethereum with neochain in all files - repalce ETHEREUM with NEOCHAIN in all files - repalce Ethereum with Neochain in all files - repalce ether with neochain in all files - repalce Ether with Neochain in all files - repalce eth with vch in all files - repalce ETH with VCH in all files
5- replace back nch_ with eth_ to restore api default functions calls
把eth_替换成nch_,用来存储调用的API
6- replace back mnchod with method
替换method
7- replace back Mnchod with Method
替换Method
8- replace back wvec with weth to restore the word wheter
替换weth
9- replace default rpc port (we’ll use port 7575):
修改RPC 端口,neochain 利用7575 端口 - in file go-neochain\cmd\utils\flags.go line 71 把以太坊默认端口8545修改成7575 replace: 替换 RPCPortFlag = cli.IntFlag{ Name: "rpcport", Usage: "HTTP-RPC server listening port", Value: 8545, } with: RPCPortFlag = cli.IntFlag{ Name: "rpcport", Usage: "HTTP-RPC server listening port", Value: 7575, } 在neochain_js.go 第4108行 也进行替换 - in file go-neochain\jsre\neochain_js.go line 4108 replace: 替换 var HttpProvider = function (host) { this.host = host || 'http://localhost:8545'; }; with: var HttpProvider = function (host) { this.host = host || 'http://localhost:7575'; }; 在admin_args.go 第130行也需要进行替换 - in file go-neochain\rpc\api\admin_args.go line 130 replace: args.ListenPort = 8545 with: args.ListenPort = 7575 在comms.go 127行也进行替换 in file go-neochain\rpc\comms\comms.go line 127 replace: if strings.HasPrefix(endpoint, "rpc:") { parts := strings.Split(endpoint, ":") addr := "http://localhost" port := uint(8545) if len(parts) >= 3 { addr = parts[1] + ":" + parts[2] } with: if strings.HasPrefix(endpoint, "rpc:") { parts := strings.Split(endpoint, ":") addr := "http://localhost" port := uint(7575) if len(parts) >= 3 { addr = parts[1] + ":" + parts[2] } 替换ethereum的p2p端口,在neochain 中,我们利用17575端口
10- replace default p2p port (we’ll use port 17575):
- in file go-neochain\cmd\utils\flags.go line 315 replace: 替换 ListenPortFlag = cli.IntFlag{ Name: "port", Usage: "Network listening port", Value: 30303, } with: ListenPortFlag = cli.IntFlag{ Name: "port", Usage: "Network listening port", Value: 17575, } 替换ethereum的discovery port, 把30301端口替换成27575端口。neochain中我们利用 27575端口。
11- replace default discovery port (we’ll use port 27575):
- in go-neochain\cmd\bootnode\main.go line 37
replace:替换
listenAddr = flag.String(“addr”, “:30301″, “listen address”)
with:
listenAddr = flag.String(“addr”, “:27575″, “listen address”)
1- 停止ethereum的种子节点 disable default seed nodes:
- in go-neochain\vch\backend.go line 71
replace:
defaultBootNodes = []*discover.Node{
// VCH/DEV Go Bootnodes
discover.MustParseNode("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303"), // IE
discover.MustParseNode("enode://de471bccee3d042261d52e9bff31458daecc406142b401d4cd848f677479f73104b9fdeb090af9583d3391b7f10cb2ba9e26865dd5fca4fcdc0fb1e3b723c786@54.94.239.50:30303"), // BR
discover.MustParseNode("enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303"), // SG
// VCH/DEV cpp-neochain (poc-9.vchdev.com)
discover.MustParseNode("enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"),}
defaultTestNetBootNodes = []*discover.Node{
discover.MustParseNode("enode://e4533109cc9bd7604e4ff6c095f7a1d807e15b38e9bfeb05d3b7c423ba86af0a9e89abbf40bd9dde4250fef114cd09270fa4e224cbeef8b7bf05a51e8260d6b8@94.242.229.4:40404"),
discover.MustParseNode("enode://8c336ee6f03e99613ad21274f269479bf4413fb294d697ef15ab897598afb931f56beb8e97af530aee20ce2bcba5776f4a312bc168545de4d43736992c814592@94.242.229.203:30303"),}
替换成:
with:
defaultBootNodes = []*discover.Node{
}
defaultTestNetBootNodes = []*discover.Node{
}
2- 生成预挖的公钥和私钥对:create premine address keypair:
- 需要一个公钥地址,来产生neochain的创始区块,并且需要控制它的私钥来后面花费公钥上面的币。
- 第一步,通过一个随机数产生器,我们来产生32位的私钥,最简单的做法就是通过下面命令产生:openssl rand -hex 32
- 第二步,我们得到私钥为: eb1b1d5ffc51b07a64e622413479bb87xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (只展示出一部分)
- 第三步,我们需要通过私钥来得到公钥,我们建立一个新的文件 name: priv.txt , 然后复制privatekey 到这个txt文件
- 第四步,我们可以通过ethereum的客户端来产生公钥,使用一下命令: geth account import priv.txt (如果我们没有ethereum客户端,我们需要自己编译gvch并且采用相同的命令行)
- 我们可以得到下面的地址: {861fddd8a92457efb9f016517db38eb7fe586a6f}
- 出于安全原因,删除了priv.txt
3- 创建创始区块 create the genesis block string:
- 我们利用 script gengen.go 来创建创始区块,在gengen.go 中可以编辑一个货币系统的参数,包括币的总量,区块奖励,区块时间,区块难度信息,等等。
- 根据私链开发的需要,我们可以修改gengen.go 中的各种区块链的参数。
- 第一 修改区块链alive的时间戳
第80行,修改时间unix时间戳,用16进制。
(line 80): newGenesis.Timestamp="0x569CBF7F"
- 第二 我们把premine的地址替换成我们的地址
第90行(line 90): newGenesis.Coinbase="0x861fddd8a92457efb9f016517db38eb7fe586a6f"
- 第三 我们修改premine的数量
第92行 (line 92): premine:=[]byte('{"0x861fddd8a92457efb9f016517db38eb7fe586a6f":{"balance": "10000000000000000000000000"}}')
(格式为:premine address 和premine amount +18个0)
- 第四 我们也可以修改nonce、初始难度、gas limit 等信息
因为neochain, 没有太多人参与,因为我们把难度设置成cpu可以挖矿。
- 第五 所有参数修改好后,我们就可以保存,然后运行,得到创始区块的信息。 用以下命令来产生创始区块: command: go run gengen.go
- 第六 我们把运行结果复制到: go-neochain\core\default_genesis.go line 30
const defaultGenesisBlock = "H4sIAAAJbogA/6yRTWrDMBCF76J1FpZl/Ti7xGnaRVsK7QVmpFEjkO1iK+ASfPeqNhQK7SKQWQgkzfvmPenCnvvOEtuyYip+lSjZhr2FlsYE7cfSIFXd7I/6mC9eYKAuPcB4+kN6fWXi3ZQGOECCBcg5IhmHFYlK59XYWmjLrRG6oAolOSHAoXCoaosONQhDnGSBHE3pIQPvYXwMbUgLT/GdyWeH4H2w55g+V9v8Z/xTmE43TNP0oUMY14c1invnnIG6rKQmj7UvuJJc5wCGUHuSRoHyWbeLsbdse7lGlbub3n2PyoDX1A/wnjfdOcYN20OE9X/5/3bnef4KAAD//0BefdIIAgAA"
第七 – 修改区块奖励
- 在go-neochain\core\fees.go line 23
replace:
var BlockReward *big.Int = big.NewInt(5e+18)
with:
var BlockReward *big.Int = big.NewInt(0.01e+18)
- 在neochain中,我们把区块奖励设置成0.01
第八 – 保存所有修改后,可以编译客户端 (编译客户端的说明详见:see ethereum docs)
第九- 把ethereum的hardnode和keys,替换成我们自己的hardnode和keys
go-neochain\vch\backend.go line 71
replace:替换
defaultBootNodes = []*discover.Node{
// VCH/DEV Go Bootnodes
//discover.MustParseNode("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303"), // IE
//discover.MustParseNode("enode://de471bccee3d042261d52e9bff31458daecc406142b401d4cd848f677479f73104b9fdeb090af9583d3391b7f10cb2ba9e26865dd5fca4fcdc0fb1e3b723c786@54.94.239.50:30303"), // BR
//discover.MustParseNode("enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303"), // SG
// VCH/DEV cpp-neochain (poc-9.vchdev.com)
//discover.MustParseNode("enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"),
}
with:
defaultBootNodes = []*discover.Node{
// VCH/DEV Go Bootnodes
discover.MustParseNode("enode://11936c3b31f940391025bba951777d4eafeffbd8aa24bf371b5166b2da6d69e9844b4778a35f68c106af8583be5c4500e69bb3639c10a30eabb311a044ac5202@62.210.105.88:17575"), // FR
discover.MustParseNode("enode://e1c30651e549149eb2bd68b77d5ca2a0ea662cd6364b846f456b5c12bd29978f738f55679b25538665d8797d3177c7160a41f079dbaf958b28e9aeb880647d75@139.196.109.133:17575"), // CN
}
第十- 最后再重新编译客户端,并发布各种版本的客户端。 网络就可以alive,可以参考ethereum的挖矿说明,包括如何搭建矿池,让矿工参与挖矿。