Try โ€‚HackMD Logoโ€‰HackMD

Creating a Genesis File

tags: Technical Templates

Here's an example that produces content for a genesis.json file that can be used to spin up a new chain. It described a simple setup wherein 2 global and 2 are selected in each round and each is responsible for producing 3 consecutive blocks. The selection of GVs is based on the proportional distribution of delegate votes. This example has one "pinned" validator that's always picked, and the other is randomly selected from delegates whose weighted rank falls in the top 100.

In order to be eligible, validators must register and stake at least 5000 FIRE for 1 Epoch (5,184,000 blocks โ‰ˆ 3 months) to become bonded.

This is a complete example, meaning you can use it to spin up a node.

const genesisConfig = { // Feature Flags "UpgradeCfg": { "Level": "latest" }, // Governance "GovernanceInfo": { "ConsensusGroupInfoMap": { // Groups: // - Global Block Producers "00000000000000000001": { // Number of validators active at a time "NodeCount": 2, // Target block time (in seconds) "Interval": 1, // Number of consecutive blocks to be produced by a validator "PerCount": 3, // Number of randomly selected candidates "RandCount": 1, // Maximum rank of randomly selected candidates "RandRank": 100, // Number of rounds until re-election of validators "Repeat": 1, // Pre-flight Validation Level // - 0: Full (address + nonce) - default // - 1: Address (address only) - faster, but more prone to collisions and replays "CheckLevel": 0, // Token used for voting "CountingTokenId": "t4649524520544f4b454e8eb5", // Registration Conditions // - 1: Must meet staking requirements // - 2: Must be a registered validator "RegisterConditionId": 1, "RegisterConditionParam": { // Token used for staking "StakeToken": "t4649524520544f4b454e8eb5", // Minimum stake amount "StakeAmount": 5000000000000000000000, // Minimum stake duration (in blocks โ‰ˆ seconds) "StakeHeight": 5184000 }, // Voting Conditions "VoteConditionId": 1, "VoteConditionParam": {} }, // - Account Block Producers "00000000000000000002": { "NodeCount": 2, "Interval": 3, "PerCount": 1, "RandCount": 2, "RandRank": 100, "Repeat": 48, "CheckLevel": 0, "CountingTokenId": "t4649524520544f4b454e8eb5", "RegisterConditionId": 1, "RegisterConditionParam": { "StakeAmount": 5000000000000000000000, "StakeToken": "t4649524520544f4b454e8eb5", "StakeHeight": 5184000 }, "VoteConditionId": 1, "VoteConditionParam": {} } }, // Registered Validators "RegistrationInfoMap": { "00000000000000000001": { // Node ID => Validator Info "uno": { // Address from which blocks are produced "NodeAddr": "fx67244b1e041242740976fe55780fd587b7ab21469dcc763dc2", // Address used for staking "StakeAddr": "fx67244b1e041242740976fe55780fd587b7ab21469dcc763dc2", // Amount staked "Amount": 1000000000000000000000000, // Staking duration (in blocks โ‰ˆ seconds) "WithdrawHeight": 5184000, // Block rewards are claimable after N blocks (1 = next block) "RewardTime": 1, // Block height at which the group was dissolved (0 = still active) "RevokeTime": 0, // Array of all producer addresses ever registered by this validator "Members": [ "fx67244b1e041242740976fe55780fd587b7ab21469dcc763dc2" ] }, // Validator 2 "dos": { "NodeAddr": "fx73d4a2a3667231950206bf79fe8be10fda4e3341d626ed42ac", "StakeAddr": "fx73d4a2a3667231950206bf79fe8be10fda4e3341d626ed42ac", "Amount": 1000000000000000000000000, "WithdrawHeight": 5184000, "RewardTime": 1, "RevokeTime": 0, "Members": [ "fx73d4a2a3667231950206bf79fe8be10fda4e3341d626ed42ac" ] } } }, // Election Results "VoteStatusMap": { // Group ID => Results "00000000000000000001": { // Voter address => Validator ID "fx0cb9a65cff58bea9215d778bcdd178146610c2a3de9281642b": "uno", "fxc63501234bbd65d8ad2b73316f632c1c9405dd056494b74918": "dos" } } }, // Assets "AssetInfo": { "TokenInfoMap": { // Token ID => Token Info "t4649524520544f4b454e8eb5": { // Name "TokenName": "Firechain Token", // Symbol "TokenSymbol": "FIRE", // Total supply (in base units) "TotalSupply": 1000000000000000000000000000, // Decimals "Decimals": 18, // Token owner/creator "Owner": "fx0cb9a65cff58bea9215d778bcdd178146610c2a3de9281642b", // Maximum supply (in base units) "MaxSupply": 100000000000000000000000000000, // Burning restricted? (true = only creator can burn) "BurnRestricted": false, // Mintable? (true = supply is not fixed) "IsMintable": true } } }, // Heat-related Staking "HeatInfo": { // Beneficiaries "StakeBeneficialMap": { // Address => Total Committed (Self-Staked + Delegated) "fx0cb9a65cff58bea9215d778bcdd178146610c2a3de9281642b": 1000000000000000000000, "fx73d4a2a3667231950206bf79fe8be10fda4e3341d626ed42ac": 1000000000000000000000, "fx67244b1e041242740976fe55780fd587b7ab21469dcc763dc2": 500000000000000000000 }, // Stakeholders "StakeInfoMap": { // Staker => [Stake Info] "fx0cb9a65cff58bea9215d778bcdd178146610c2a3de9281642b": [ { // Amount staked "Amount": 1000000000000000000000, // Staking duration (in blocks โ‰ˆ seconds, min = 600) "WithdrawHeight": 86400, // Beneficiary of heat capacity (can be different from staker) "BeneficialAddr": "fx0cb9a65cff58bea9215d778bcdd178146610c2a3de9281642b" } ], "fx73d4a2a3667231950206bf79fe8be10fda4e3341d626ed42ac": [ { "Amount": 1000000000000000000000, "WithdrawHeight": 86400, "BeneficialAddr": "fx73d4a2a3667231950206bf79fe8be10fda4e3341d626ed42ac" }, { "Amount": 500000000000000000000, "WithdrawHeight": 86400, "BeneficialAddr": "fx67244b1e041242740976fe55780fd587b7ab21469dcc763dc2" } ] } }, // Initial Account States "AccountBalanceMap": { // Address => Balances "fx0cb9a65cff58bea9215d778bcdd178146610c2a3de9281642b": { // Token ID => Balance "t4649524520544f4b454e8eb5": 100000000000000000000 }, "fx67244b1e041242740976fe55780fd587b7ab21469dcc763dc2": { "t4649524520544f4b454e8eb5": 100000000000000000000 } } }; console.log(JSON.stringify(genesisConfig, null, 2));