make all
在./build/bin 目录下可以看到下列二进制文件
abidump
abigen
bootnode
checkpoint-admin
clef
devp2p
ethkey
evm
faucet
geth
p2psim
puppeth
rlpdump
以本地启动四个节点为例
node1
node2
node3
node4
将geth 拷贝到每个文件夹下,执行:
./geth --datadir ./data account new
创建新账户
Clique的共识节点设置在区块头的extraData中,因此创世块需要进行配置,当然后续也可以增减共识节点。可以使用puppeth工具来进行交互式配置。
> puppeth
+ — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -+
| Welcome to puppeth, your Ethereum private network manager |
| |
| This tool lets you create a new Ethereum network down to |
| the genesis block, bootnodes, miners and ethstats servers |
| without the hassle that it would normally entail. |
| |
| Puppeth uses SSH to dial in to remote servers, and builds |
| its network components out of Docker containers using the |
| docker-compose toolset. |
+ — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -+
Please specify a network name to administer (no spaces, please)
> mochain
Sweet, you can set this via — network=mochain next time!
选择 2
What would you like to do? (default = stats)
1. Show network stats
2. Configure new genesis
3. Track new remote server
4. Deploy network components
> 2
选择 1
What would you like to do? (default = create)
1. Create new genesis from scratch
2. Import already existing genesis
> 1
选择 2 Clique
Which consensus engine to use? (default = clique)
1. Ethash - proof-of-work
2. Clique - proof-of-authority
> 2
How many seconds should blocks take? (default = 15)
>
增加可以出块的钱包地址,将第一步生成的四个地址加入
Which accounts are allowed to seal? (mandatory at least one)
> 0x
填入需要预先分配代币的地址
Which accounts should be pre-funded? (advisable at least one)
> 0x
Should the precompile-addresses (0x1 .. 0xff) be pre-funded with 1 wei? (advisable yes)
> no
可以指定或默认随机
Specify your chain/network ID if you want an explicit one (default = random)
>
选择2
What would you like to do? (default = stats)
1. Show network stats
2. Manage existing genesis
3. Track new remote server
4. Deploy network components
> 2
选择2
1. Modify existing configurations
2. Export genesis configurations
3. Remove genesis configuration
> 2
导出json文件
Which folder to save the genesis specs into? (default = current)
Will create mochain.json, mochain-aleth.json, mochain-harmony.json, mochain-parity.json
>
生成的json文件:
{
"config": {
"chainId": 25228,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"clique": {
"period": 10,
"epoch": 30000
}
},
"nonce": "0x0",
"timestamp": "0x603f5a71",
"extraData": "0x000000000000000000000000000000000000000000000000000000000000000087ba503cce4ca532b3b31ffa67fbd32fa5409a600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"87ba503cce4ca532b3b31ffa67fbd32fa5409a60": {
"balance": "0x33b2e3c9fd0803ce8000000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
NOTE 初始化代币供应总量为0x33b2e3c9fd0803ce8000000 ,10亿
solc --bin-runtime -o ./output ./StakingProxy.sol
在output 文件夹下打开cunpStaking.bin-runtime
6080604052600436106100a75760003560e01c80638da5cb5b116100645780638da5cb5b14610249578063b83dd5f0146102a0578063b88a802f14610305578063e7cd4a0414610334578063f3e14f1e1461039d578063f51e181a146103c8576100a7565b8063165defa4146100ac57806319ab453c146100d75780632e0b78f61461014057806336ef9d4214610193578063392e53cd146101f857806369ba2b3414610227575b600080fd5b3480156100b857600080fd5b506100c16103f3565b6040518082815260200191505060405180910390f35b3480156100e357600080fd5b50610126600480360360208110156100fa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103f9565b604051808215151515815260200191505060405180910390f35b34801561014c57600080fd5b506101796004803603602081101561016357600080fd5b81019080803590602001909291905050506104ec565b604051808215151515815260200191505060405180910390f35b34801561019f57600080fd5b506101e2600480360360208110156101b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610864565b6040518082815260200191505060405180910390f35b34801561020457600080fd5b5061020d6108ac565b604051808215151515815260200191505060405180910390f35b61022f6108bf565b604051808215151515815260200191505060405180910390f35b34801561025557600080fd5b5061025e610b69565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102ac57600080fd5b506102ef600480360360208110156102c357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b8f565b6040518082815260200191505060405180910390f35b34801561031157600080fd5b5061031a610cca565b604051808215151515815260200191505060405180910390f35b34801561034057600080fd5b506103836004803603602081101561035757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610efc565b604051808215151515815260200191505060405180910390f35b3480156103a957600080fd5b506103b2610fe6565b6040518082815260200191505060405180910390f35b3480156103d457600080fd5b506103dd610fec565b6040518082815260200191505060405180910390f35b60065481565b6000600860009054906101000a900460ff161561041957600190506104e7565b6001600860006101000a81548160ff02191690831515021790555081600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550620f42406007819055507fcbca47dbb49237fa82c3f852fec4b0c30b51f4871383fe287cab03847e1ab8fc82604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1600190505b919050565b600080479050600061051d60055461050f60065485610ff290919063ffffffff16565b610ff290919063ffffffff16565b90506105288161107b565b506000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548411156105dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f6e6f7420656e6f756768207374616b696e672062616c616e636500000000000081525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc859081150290604051600060405180830381858888f19350505050158015610623573d6000803e3d6000fd5b5061063984600654610ff290919063ffffffff16565b600681905550610690846000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ff290919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414156107ee5760008090505b6003805490508160ff1610156107ec573373ffffffffffffffffffffffffffffffffffffffff1660038260ff168154811061075657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156107df5760038160ff16815481106107ad57fe5b9060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556107ec565b808060010191505061071f565b505b7f456422821874d180bb4c7cf7a364a082daa0e1271d7fa3984bf3f13e6c0d8dc33385604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1600192505050919050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600860009054906101000a900460ff1681565b60006108ca33611244565b61093c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f6e6f7420696e2077686974656c6973740000000000000000000000000000000081525060200191505060405180910390fd5b6000479050600061097e3461097060055461096260065487610ff290919063ffffffff16565b610ff290919063ffffffff16565b610ff290919063ffffffff16565b90506109898161107b565b50610993336112ec565b15610a30576109e9346000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461139490919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ada565b346000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060033390806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505b610aef3460065461139490919063ffffffff16565b6006819055507f8f169816223f856d6f6a5945e3f7c520efe6c139d4152b6bb65e454babb2f2cb3334604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a160019250505090565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806006541415610ba45760009050610cc5565b60004790506000610bd4600554610bc660065485610ff290919063ffffffff16565b610ff290919063ffffffff16565b90506000610c3f600654610c316000808973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460075461141c90919063ffffffff16565b6114a290919063ffffffff16565b90506000610c6a600754610c5c848661141c90919063ffffffff16565b6114a290919063ffffffff16565b9050610cbe81600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461139490919063ffffffff16565b9450505050505b919050565b6000610cd533611244565b610d47576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f6e6f7420696e207768697465206c69737400000000000000000000000000000081525060200191505060405180910390fd5b60004790506000610d77600554610d6960065485610ff290919063ffffffff16565b610ff290919063ffffffff16565b9050610d828161107b565b610d9157600192505050610ef9565b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000811115610e86573373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610e24573d6000803e3d6000fd5b50610e3a81600554610ff290919063ffffffff16565b6005819055506000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b7f054ac072cfee9d4b5dcae49329e8accc0546e627503db67d88f4b04e382c2fbc3382604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1600193505050505b90565b6000610f06611531565b610f0f82611244565b610f7a5760028290806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505b7fc151c9cfeed0baed60c415478666c678be2d0ce4d9a711436241e9dd30d55dc982604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a160019050919050565b60055481565b60075481565b60008282111561106a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b600082840390508091505092915050565b60008082111561123a5760008090505b6003805490508160ff16101561123057600060038260ff16815481106110ad57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905060006111436006546111356000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460075461141c90919063ffffffff16565b6114a290919063ffffffff16565b9050600061116e600754611160848961141c90919063ffffffff16565b6114a290919063ffffffff16565b90506111c281600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461139490919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061121a8160055461139490919063ffffffff16565b600581905550505050808060010191505061108b565b506001905061123f565b600090505b919050565b600080600090505b6002805490508160ff1610156112e1578273ffffffffffffffffffffffffffffffffffffffff1660028260ff168154811061128357fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156112d45760019150506112e7565b808060010191505061124c565b50600090505b919050565b600080600090505b6003805490508160ff161015611389578273ffffffffffffffffffffffffffffffffffffffff1660038260ff168154811061132b57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561137c57600191505061138f565b80806001019150506112f4565b50600090505b919050565b600080828401905083811015611412576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b60008083141561142f576000905061149c565b600082840290508284828161144057fe5b0414611497576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806116d86021913960400191505060405180910390fd5b809150505b92915050565b6000808211611519576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525060200191505060405180910390fd5b600082848161152457fe5b0490508091505092915050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660405160200180806116a8603091396030018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401915050604051602081830303815290604052906116a4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561166957808201518184015260208101905061164e565b50505050905090810190601f1680156116965780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5056fe4f6e6c792074686520636f6e7472616374206f776e6572206d617920706572666f726d207468697320616374696f6e3a536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a265627a7a72315820726e31aedad00ab6fe760bdf28261d9fe5b10fa4a81f3a78cb408c6df8fce03564736f6c63430005100032
在mochain.json文件中"alloc" 中加入
"1000000000000000000000000000000000000001":{
"balance": "0x0",
"code":"6080604052600436106100a75760003560e01c80638da5cb5b116100645780638da5cb5b14610249578063b83dd5f0146102a0578063b88a802f14610305578063e7cd4a0414610334578063f3e14f1e1461039d578063f51e181a146103c8576100a7565b8063165defa4146100ac57806319ab453c146100d75780632e0b78f61461014057806336ef9d4214610193578063392e53cd146101f857806369ba2b3414610227575b600080fd5b3480156100b857600080fd5b506100c16103f3565b6040518082815260200191505060405180910390f35b3480156100e357600080fd5b50610126600480360360208110156100fa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103f9565b604051808215151515815260200191505060405180910390f35b34801561014c57600080fd5b506101796004803603602081101561016357600080fd5b81019080803590602001909291905050506104ec565b604051808215151515815260200191505060405180910390f35b34801561019f57600080fd5b506101e2600480360360208110156101b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610864565b6040518082815260200191505060405180910390f35b34801561020457600080fd5b5061020d6108ac565b604051808215151515815260200191505060405180910390f35b61022f6108bf565b604051808215151515815260200191505060405180910390f35b34801561025557600080fd5b5061025e610b69565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102ac57600080fd5b506102ef600480360360208110156102c357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b8f565b6040518082815260200191505060405180910390f35b34801561031157600080fd5b5061031a610cca565b604051808215151515815260200191505060405180910390f35b34801561034057600080fd5b506103836004803603602081101561035757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610efc565b604051808215151515815260200191505060405180910390f35b3480156103a957600080fd5b506103b2610fe6565b6040518082815260200191505060405180910390f35b3480156103d457600080fd5b506103dd610fec565b6040518082815260200191505060405180910390f35b60065481565b6000600860009054906101000a900460ff161561041957600190506104e7565b6001600860006101000a81548160ff02191690831515021790555081600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550620f42406007819055507fcbca47dbb49237fa82c3f852fec4b0c30b51f4871383fe287cab03847e1ab8fc82604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1600190505b919050565b600080479050600061051d60055461050f60065485610ff290919063ffffffff16565b610ff290919063ffffffff16565b90506105288161107b565b506000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548411156105dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f6e6f7420656e6f756768207374616b696e672062616c616e636500000000000081525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc859081150290604051600060405180830381858888f19350505050158015610623573d6000803e3d6000fd5b5061063984600654610ff290919063ffffffff16565b600681905550610690846000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ff290919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414156107ee5760008090505b6003805490508160ff1610156107ec573373ffffffffffffffffffffffffffffffffffffffff1660038260ff168154811061075657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156107df5760038160ff16815481106107ad57fe5b9060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556107ec565b808060010191505061071f565b505b7f456422821874d180bb4c7cf7a364a082daa0e1271d7fa3984bf3f13e6c0d8dc33385604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1600192505050919050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600860009054906101000a900460ff1681565b60006108ca33611244565b61093c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f6e6f7420696e2077686974656c6973740000000000000000000000000000000081525060200191505060405180910390fd5b6000479050600061097e3461097060055461096260065487610ff290919063ffffffff16565b610ff290919063ffffffff16565b610ff290919063ffffffff16565b90506109898161107b565b50610993336112ec565b15610a30576109e9346000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461139490919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ada565b346000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060033390806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505b610aef3460065461139490919063ffffffff16565b6006819055507f8f169816223f856d6f6a5945e3f7c520efe6c139d4152b6bb65e454babb2f2cb3334604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a160019250505090565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806006541415610ba45760009050610cc5565b60004790506000610bd4600554610bc660065485610ff290919063ffffffff16565b610ff290919063ffffffff16565b90506000610c3f600654610c316000808973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460075461141c90919063ffffffff16565b6114a290919063ffffffff16565b90506000610c6a600754610c5c848661141c90919063ffffffff16565b6114a290919063ffffffff16565b9050610cbe81600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461139490919063ffffffff16565b9450505050505b919050565b6000610cd533611244565b610d47576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f6e6f7420696e207768697465206c69737400000000000000000000000000000081525060200191505060405180910390fd5b60004790506000610d77600554610d6960065485610ff290919063ffffffff16565b610ff290919063ffffffff16565b9050610d828161107b565b610d9157600192505050610ef9565b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000811115610e86573373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610e24573d6000803e3d6000fd5b50610e3a81600554610ff290919063ffffffff16565b6005819055506000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b7f054ac072cfee9d4b5dcae49329e8accc0546e627503db67d88f4b04e382c2fbc3382604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1600193505050505b90565b6000610f06611531565b610f0f82611244565b610f7a5760028290806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505b7fc151c9cfeed0baed60c415478666c678be2d0ce4d9a711436241e9dd30d55dc982604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a160019050919050565b60055481565b60075481565b60008282111561106a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b600082840390508091505092915050565b60008082111561123a5760008090505b6003805490508160ff16101561123057600060038260ff16815481106110ad57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905060006111436006546111356000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460075461141c90919063ffffffff16565b6114a290919063ffffffff16565b9050600061116e600754611160848961141c90919063ffffffff16565b6114a290919063ffffffff16565b90506111c281600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461139490919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061121a8160055461139490919063ffffffff16565b600581905550505050808060010191505061108b565b506001905061123f565b600090505b919050565b600080600090505b6002805490508160ff1610156112e1578273ffffffffffffffffffffffffffffffffffffffff1660028260ff168154811061128357fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156112d45760019150506112e7565b808060010191505061124c565b50600090505b919050565b600080600090505b6003805490508160ff161015611389578273ffffffffffffffffffffffffffffffffffffffff1660038260ff168154811061132b57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561137c57600191505061138f565b80806001019150506112f4565b50600090505b919050565b600080828401905083811015611412576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b60008083141561142f576000905061149c565b600082840290508284828161144057fe5b0414611497576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806116d86021913960400191505060405180910390fd5b809150505b92915050565b6000808211611519576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525060200191505060405180910390fd5b600082848161152457fe5b0490508091505092915050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660405160200180806116a8603091396030018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401915050604051602081830303815290604052906116a4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561166957808201518184015260208101905061164e565b50505050905090810190601f1680156116965780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5056fe4f6e6c792074686520636f6e7472616374206f776e6572206d617920706572666f726d207468697320616374696f6e3a536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a265627a7a72315820726e31aedad00ab6fe760bdf28261d9fe5b10fa4a81f3a78cb408c6df8fce03564736f6c63430005100032"
},
在每个文件夹下执行:
./geth --datadir ./data/ init ../mochain.json
假定四个节点的端口为2000 ~ 2003,我们暂时只开放node1的http端口,默认为8545 首先通过下面的命令打印各个节点的公钥
./bootnode -nodekey ./data/geth/nodekey -writeaddress
也可以将节点列表放入/geth/static-nodes.json文件中,让节点主动连接和重连:https://geth.ethereum.org/docs/interface/peer-to-peer
[
"enode://7b9a62ee9350e0d3a86dc29f97875542a3b0a7765c177218bcbcaa2bbb0da945feb87a137f510d6ac0c976456e0d9a624d2534298ed45e07fa455b55ebfa1832@127.0.0.1:2000",
"enode://d64121d4de07d8acf82e65a8ac7e2e331d4ff77e29496433366570cb0f632f8a60e7e64dfc0853a9f6bb3880b0436df77c9108fbd9fe762980d17d7f1ec92289@127.0.0.1:2001",
"enode://55f5d42ed95300427742a0cfb80a3143e2b32138f6ae3ce24fdb4393d32bc6040d79fb7cb0aba91352c00b4fcf83ba76df9a75cf3c9f6360740b19f60de57061@127.0.0.1:2002",
"enode://aa8024d469b6428c169170569aff7f56def36ec419ee80d208ffeebec460c0ce009760683af6ea371eba452e9cdfc3dccd4aed5ec336f26baf2982e6085e6f05@127.0.0.1:2003"
]
启动命令
./geth --datadir ./data --networkid 55661 --port 2000 --http --http.addr 0.0.0.0 --allow-insecure-unlock --bootnodes 'enode://e6ea761edf435c03e41665db06437ad8f2d87aa36bfba91540af72767f9feff32c9f28643730c086499ba783079287abc2ffa07dd70b066bb0511c8aa28ffd07@172.17.16.14:2000,enode://0e7b82f9effeef6f92ec60150740b7753392a8d3f0f8d978a0832924dd2184790d263d15a3b1894a23b2c65109ca290b22249ce0a612c0069785bf0ca31c3302@172.17.16.14:2001,enode://14e89b97966e0e9cf69b469c6216f3eea5b73e7c3ec73a52de57949ecf2bab5e7973bcffbcb78dceeb0db9ae786d2fe354b6dce9528f9d9f590c33a0292fe045@172.17.16.16:2002,enode://991951ba49e7510265b608bc718e2ba895f85a800173ddc0bf7fb0997c681bba90fda5c46bfc8f80ed888b6bad3ba4de649d41469ee6e241d75bdbdfa8d0a002@172.17.16.16:2003,enode://05f7c4c686e39ab2bc33c95ddc168231a08ac793ab1d71e69ef04c35958362030a6b6398d7226242bc9eafbf0bd94f396480de0524d6587d00bcbacaf306a54d@172.17.16.16:2004' --unlock c5cb983c799b900db19b8699330c311a28910a3c console
./geth --datadir ./data --networkid 55661 --port 2001 --bootnodes 'enode://e6ea761edf435c03e41665db06437ad8f2d87aa36bfba91540af72767f9feff32c9f28643730c086499ba783079287abc2ffa07dd70b066bb0511c8aa28ffd07@172.17.16.14:2000,enode://0e7b82f9effeef6f92ec60150740b7753392a8d3f0f8d978a0832924dd2184790d263d15a3b1894a23b2c65109ca290b22249ce0a612c0069785bf0ca31c3302@172.17.16.14:2001,enode://14e89b97966e0e9cf69b469c6216f3eea5b73e7c3ec73a52de57949ecf2bab5e7973bcffbcb78dceeb0db9ae786d2fe354b6dce9528f9d9f590c33a0292fe045@172.17.16.16:2002,enode://991951ba49e7510265b608bc718e2ba895f85a800173ddc0bf7fb0997c681bba90fda5c46bfc8f80ed888b6bad3ba4de649d41469ee6e241d75bdbdfa8d0a002@172.17.16.16:2003,enode://05f7c4c686e39ab2bc33c95ddc168231a08ac793ab1d71e69ef04c35958362030a6b6398d7226242bc9eafbf0bd94f396480de0524d6587d00bcbacaf306a54d@172.17.16.16:2004' --unlock 0ec132b5cccb68bdee93f1351e5303c658847c2d console
./geth --datadir ./data --networkid 55661 --port 2002 --bootnodes 'enode://e6ea761edf435c03e41665db06437ad8f2d87aa36bfba91540af72767f9feff32c9f28643730c086499ba783079287abc2ffa07dd70b066bb0511c8aa28ffd07@172.17.16.14:2000,enode://0e7b82f9effeef6f92ec60150740b7753392a8d3f0f8d978a0832924dd2184790d263d15a3b1894a23b2c65109ca290b22249ce0a612c0069785bf0ca31c3302@172.17.16.14:2001,enode://14e89b97966e0e9cf69b469c6216f3eea5b73e7c3ec73a52de57949ecf2bab5e7973bcffbcb78dceeb0db9ae786d2fe354b6dce9528f9d9f590c33a0292fe045@172.17.16.16:2002,enode://991951ba49e7510265b608bc718e2ba895f85a800173ddc0bf7fb0997c681bba90fda5c46bfc8f80ed888b6bad3ba4de649d41469ee6e241d75bdbdfa8d0a002@172.17.16.16:2003,enode://05f7c4c686e39ab2bc33c95ddc168231a08ac793ab1d71e69ef04c35958362030a6b6398d7226242bc9eafbf0bd94f396480de0524d6587d00bcbacaf306a54d@172.17.16.16:2004' --unlock 5fdb0c1082a21994b1d66bfe9b895c199c88f14f console
./geth --datadir ./data --networkid 55661 --port 2003 --bootnodes 'enode://e6ea761edf435c03e41665db06437ad8f2d87aa36bfba91540af72767f9feff32c9f28643730c086499ba783079287abc2ffa07dd70b066bb0511c8aa28ffd07@172.17.16.14:2000,enode://0e7b82f9effeef6f92ec60150740b7753392a8d3f0f8d978a0832924dd2184790d263d15a3b1894a23b2c65109ca290b22249ce0a612c0069785bf0ca31c3302@172.17.16.14:2001,enode://14e89b97966e0e9cf69b469c6216f3eea5b73e7c3ec73a52de57949ecf2bab5e7973bcffbcb78dceeb0db9ae786d2fe354b6dce9528f9d9f590c33a0292fe045@172.17.16.16:2002,enode://991951ba49e7510265b608bc718e2ba895f85a800173ddc0bf7fb0997c681bba90fda5c46bfc8f80ed888b6bad3ba4de649d41469ee6e241d75bdbdfa8d0a002@172.17.16.16:2003,enode://05f7c4c686e39ab2bc33c95ddc168231a08ac793ab1d71e69ef04c35958362030a6b6398d7226242bc9eafbf0bd94f396480de0524d6587d00bcbacaf306a54d@172.17.16.16:2004' --unlock 41f3d1a9b27c8f52f9f0d47d42884cf72b3b3934 console
输入节点密码后,启动挖矿,在控制台输入:
miner.start()
测试转账:
eth.sendTransaction({from:'87ba503cce4ca532b3b31ffa67fbd32fa5409a60', to:'a369dfa4d618b98ebd61e8725b7782625963fb84', value: web3.toWei(0.05, "ether")})
取得节点公钥后,以相同的networkid 启动节点 node5
./geth --datadir ./data --networkid 55661 --port 2004 --bootnodes 'enode://7b9a62ee9350e0d3a86dc29f97875542a3b0a7765c177218bcbcaa2bbb0da945feb87a137f510d6ac0c976456e0d9a624d2534298ed45e07fa455b55ebfa1832@127.0.0.1:2000,enode://d64121d4de07d8acf82e65a8ac7e2e331d4ff77e29496433366570cb0f632f8a60e7e64dfc0853a9f6bb3880b0436df77c9108fbd9fe762980d17d7f1ec92289@127.0.0.1:2001,enode://55f5d42ed95300427742a0cfb80a3143e2b32138f6ae3ce24fdb4393d32bc6040d79fb7cb0aba91352c00b4fcf83ba76df9a75cf3c9f6360740b19f60de57061@127.0.0.1:2002,enode://aa8024d469b6428c169170569aff7f56def36ec419ee80d208ffeebec460c0ce009760683af6ea371eba452e9cdfc3dccd4aed5ec336f26baf2982e6085e6f05@127.0.0.1:2003' --unlock a369dfa4d618b98ebd61e8725b7782625963fb84 console
node1~ node4 在控制台执行:
admin.addPeer("enode://1290aad1ef5b457e219668f02814883236ed805a2f1ac87188d44bac67e0908e5f48fa5bbb09d8f875c3641215d6a5710c31aabe875c943e7ab1f2c6cf28f33f@127.0.0.1:2004")
由共识节点发起新增节点交易
> clique.propose(<node5钱包地址>, true)
node5的控制台中执行
miner.start()
删除共识节点
clique.discard(signer_address)
质押合约使用代理模式,资产储存在StakingProxy合约中,质押和分配信息存储在cunpStaking合约中, 分配的逻辑可以通过更换合约来达到升级的目的。
质押合约接口如下:
pragma solidity ^0.5.16;
interface cunpStaking {
function init(address account,address stakingAddr) external ;
function setOwner(address newOwner) external;
function setStakingContract(address newAddress) external;
function addNewStaker(address staker) external returns(bool);
function stake() payable external returns(bool) ;
function withdraw(uint256 amount) external returns(bool);
function claimRewards() external returns(bool);
function getUserStaking(address account) external view returns(uint256) ;
function getUserRewards(address account) external view returns(uint256);
function totalStaking() external view returns(uint256);
function getStakingUsers() external view returns( address [] memory);
}
由于该合约直接部署在创世块中,需要手动初始化并设置合约的owner
function init(address account,address stakingAddr) external returns(bool);
account : 合约owner地址
stakingAddr: 代理合约的地址
修改合约Owner
function setOwner(address newOwner) external;
newOwner: owner的地址
修改质押合约的地址
function setStakingContract(address newAddress) external;
newAddress: 合约地址
增加质押白名单
function addNewStaker(address account) external returns(bool);
account: 可以质押的钱包地址
执行权限: 合约owner
节点质押
function stake()payable external returns(bool);
需要在构造交易中指定质押的ETH(MXC)
执行权限:需要在白名单内
提取收益
function claimRewards() external returns(bool);
提取质押
function withdraw(uint256 amount) external returns(bool);
amount: 提取的质押数量
查询质押数
function getUserStaking(address account) external view returns(uint);
account: 质押的地址
查询当前的收益
function getUserRewards(address account) external view returns(uint);
account: 质押的地址
查询当前的总质押
function totalStaking() external view returns(uint256);
查询当前质押的用户名单
function getStakingUsers() external view returns( address [] memory);