- At least one
MasterNode
- At least one
Rich Account
- At least two public nodes that can connect each other
Executor
Can be an address orExecutor Contract
(Vote contract among steering committee)
Here we change genesis/testnet.go
, this will allow us to build a network with peer to peer network. Furthermore you can change genesis/devnet.go
to run a dev-net in solo mode, this allows you to do test locally.
We can set the network to launch in the future.
launchTime := uint64(1530014400) // 'Tue Jun 26 2018 20:00:00 GMT+0800 (CST)'
// 50 billion for richAccount
amount := new(big.Int).Mul(big.NewInt(1e18), big.NewInt(50*1000*1000*1000))
state.SetBalance(richAccount, amount)
state.SetEnergy(richAccount, &big.Int{}, launchTime)
Setup contract code:
state.SetCode(builtin.Authority.Address, builtin.Authority.RuntimeBytecodes())
Set endorsor's balance (Not required):
state.SetBalance(endorsorAddress, thor.InitialProposerEndorsement)
state.SetEnergy(endorsorAddress, &big.Int{}, launchTime)
Note: Must update energy when touching account's balance in genesis
Add MasterNode
:
data := mustEncodeInput(builtin.Authority.ABI, "add", anode.masterAddress, anode.endorsorAddress, anode.identity)
builder.Call(tx.NewClause(&builtin.Authority.Address).WithData(data), executorAddress)
Setup contract code:
state.SetCode(builtin.Energy.Address, builtin.Energy.RuntimeBytecodes())
Set total supply:
builtin.Energy.Native(state, launchTime).SetInitialSupply(tokenSupply, energySupply)
Setup contract code:
state.SetCode(builtin.Extension.Address, builtin.Extension.RuntimeBytecodes())
Setup contract code:
state.SetCode(builtin.Params.Address, builtin.Params.RuntimeBytecodes())
Initiate Params:
// Set executor
data := mustEncodeInput(builtin.Params.ABI, "set", thor.KeyExecutorAddress, new(big.Int).SetBytes(executorAddress[:]))
builder.Call(tx.NewClause(&builtin.Params.Address).WithData(data), thor.Address{})
// Set energy reward ratio
data = mustEncodeInput(builtin.Params.ABI, "set", thor.KeyRewardRatio, thor.InitialRewardRatio)
builder.Call(tx.NewClause(&builtin.Params.Address).WithData(data), executorAddress)
// Set base gas price
data = mustEncodeInput(builtin.Params.ABI, "set", thor.KeyBaseGasPrice, thor.InitialBaseGasPrice)
builder.Call(tx.NewClause(&builtin.Params.Address).WithData(data), executorAddress)
// Set proposer endorsement
data = mustEncodeInput(builtin.Params.ABI, "set", thor.KeyProposerEndorsement, thor.InitialProposerEndorsement)
builder.Call(tx.NewClause(&builtin.Params.Address).WithData(data), executorAddress)
Setup contract code:
state.SetCode(builtin.Prototype.Address, builtin.Prototype.RuntimeBytecodes())
If your executor is an Address
, you just need to set the address when initiating Params
contract.
// Set executor
data := mustEncodeInput(builtin.Params.ABI, "set", thor.KeyExecutorAddress, new(big.Int).SetBytes(executorAddress[:]))
builder.Call(tx.NewClause(&builtin.Params.Address).WithData(data), thor.Address{})
If your executor is an Executor Contract
, you need to set contract code and approvers.
Setup contract code:
state.SetCode(builtin.Executor.Address, builtin.Executor.RuntimeBytecodes())
Set executor address in Params Contract
:
data := mustEncodeInput(builtin.Params.ABI, "set", thor.KeyExecutorAddress, new(big.Int).SetBytes(builtin.Executor.Address[:]))
builder.Call(tx.NewClause(&builtin.Params.Address).WithData(data), thor.Address{})
Add approvers in Executor Contract
:
data := mustEncodeInput(builtin.Executor.ABI, "addApprover", approver.address, thor.BytesToBytes32([]byte(approver.identity)))
builder.Call(tx.NewClause(&builtin.Executor.Address).WithData(data), executorAddress)
- Craft genesis
make thor
- Start
MasterNode
withthor -network test
- Wait for the launch time, master will propose blocks