Skip to content
On this page

Genesis Block

The genesis block is the first block in your blockchain. It's never empty, even if configs/peer/genesis.json is. Here's an example:

Genesis Block Example: alice@wonderland
json
{
  "transactions": [
    {
      "isi": [
        {
          "Register": {
            "NewDomain": {
              "id": "wonderland",
              "logo": null,
              "metadata": {
                "key": {
                  "String": "value"
                }
              }
            }
          }
        },
        {
          "Register": {
            "NewAccount": {
              "id": "alice@wonderland",
              "signatories": [
                "ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0"
              ],
              "metadata": {
                "key": {
                  "String": "value"
                }
              }
            }
          }
        },
        {
          "Register": {
            "NewAccount": {
              "id": "bob@wonderland",
              "signatories": [
                "ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0"
              ],
              "metadata": {
                "key": {
                  "String": "value"
                }
              }
            }
          }
        },
        {
          "Register": {
            "NewAssetDefinition": {
              "id": "rose#wonderland",
              "value_type": "Quantity",
              "mintable": "Infinitely",
              "metadata": {}
            }
          }
        },
        {
          "Register": {
            "NewDomain": {
              "id": "garden_of_live_flowers",
              "logo": null,
              "metadata": {}
            }
          }
        },
        {
          "Register": {
            "NewAccount": {
              "id": "carpenter@garden_of_live_flowers",
              "signatories": [
                "ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0"
              ],
              "metadata": {}
            }
          }
        },
        {
          "Register": {
            "NewAssetDefinition": {
              "id": "cabbage#garden_of_live_flowers",
              "value_type": "Quantity",
              "mintable": "Infinitely",
              "metadata": {}
            }
          }
        },
        {
          "Register": {
            "PermissionTokenDefinition": {
              "id": "can_unregister_asset_with_definition",
              "params": {
                "asset_definition_id": "Id"
              }
            }
          }
        },
        {
          "Register": {
            "PermissionTokenDefinition": {
              "id": "can_burn_asset_with_definition",
              "params": {
                "asset_definition_id": "Id"
              }
            }
          }
        },
        {
          "Register": {
            "PermissionTokenDefinition": {
              "id": "can_burn_user_assets",
              "params": {
                "asset_id": "Id"
              }
            }
          }
        },
        {
          "Register": {
            "PermissionTokenDefinition": {
              "id": "can_set_key_value_in_user_assets",
              "params": {
                "asset_id": "Id"
              }
            }
          }
        },
        {
          "Register": {
            "PermissionTokenDefinition": {
              "id": "can_remove_key_value_in_user_assets",
              "params": {
                "asset_id": "Id"
              }
            }
          }
        },
        {
          "Register": {
            "PermissionTokenDefinition": {
              "id": "can_set_key_value_in_user_metadata",
              "params": {
                "account_id": "Id"
              }
            }
          }
        },
        {
          "Register": {
            "PermissionTokenDefinition": {
              "id": "can_remove_key_value_in_user_metadata",
              "params": {
                "account_id": "Id"
              }
            }
          }
        },
        {
          "Register": {
            "PermissionTokenDefinition": {
              "id": "can_set_key_value_in_asset_definition",
              "params": {
                "asset_definition_id": "Id"
              }
            }
          }
        },
        {
          "Register": {
            "PermissionTokenDefinition": {
              "id": "can_remove_key_value_in_asset_definition",
              "params": {
                "asset_definition_id": "Id"
              }
            }
          }
        },
        {
          "Register": {
            "PermissionTokenDefinition": {
              "id": "can_mint_user_asset_definitions",
              "params": {
                "asset_definition_id": "Id"
              }
            }
          }
        },
        {
          "Register": {
            "PermissionTokenDefinition": {
              "id": "can_transfer_user_assets",
              "params": {
                "asset_id": "Id"
              }
            }
          }
        },
        {
          "Register": {
            "PermissionTokenDefinition": {
              "id": "can_transfer_only_fixed_number_of_times_per_period",
              "params": {
                "count": "Numeric",
                "period": "Numeric"
              }
            }
          }
        },
        {
          "Mint": {
            "U32": 13,
            "destination_id": {
              "AssetId": "rose##alice@wonderland"
            }
          }
        },
        {
          "Mint": {
            "U32": 44,
            "destination_id": {
              "AssetId": "cabbage#garden_of_live_flowers#alice@wonderland"
            }
          }
        },
        {
          "Register": {
            "PermissionTokenDefinition": {
              "id": "allowed_to_do_stuff",
              "params": {}
            }
          }
        },
        {
          "Register": {
            "NewRole": {
              "id": "USER_METADATA_ACCESS",
              "permissions": [
                {
                  "definition_id": "can_remove_key_value_in_user_metadata",
                  "params": {
                    "account_id": {
                      "AccountId": "alice@wonderland"
                    }
                  }
                },
                {
                  "definition_id": "can_set_key_value_in_user_metadata",
                  "params": {
                    "account_id": {
                      "AccountId": "alice@wonderland"
                    }
                  }
                }
              ]
            }
          }
        },
        {
          "Grant": {
            "PermissionToken": {
              "definition_id": "allowed_to_do_stuff",
              "params": {}
            },
            "destination_id": {
              "AccountId": "alice@wonderland"
            }
          }
        },
        {
          "Register": {
            "NewRole": {
              "id": "staff_that_does_stuff_in_genesis",
              "permissions": [
                {
                  "definition_id": "allowed_to_do_stuff",
                  "params": {}
                }
              ]
            }
          }
        },
        {
          "Grant": {
            "RoleId": "staff_that_does_stuff_in_genesis",
            "destination_id": {
              "AccountId": "alice@wonderland"
            }
          }
        }
      ]
    }
  ]
}

The genesis account is specified in the peer configuration file, configs/peer/config.json. This is the account that will submit the genesis block. The genesis account is like a super user account that has elevated privileges, but only during the genesis round. The genesis account should be signed by one of the peers, or, in other words, it should have the public key of this peer.

If you look at the example of a genesis block above, you will see that it contains instructions for registering a new domain (wonderland), two new accounts (alice@wonderland and bob@wonderland), a new asset (rose#wonderland) and a Mint instruction for this asset, as well as several permission tokens and roles. Both new accounts are signed with the ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0 public key.

Note

Iroha is case-sensitive, meaning that Alice@wonderland is different from alice@wonderland. It should go without saying that alice@wonderland is not the same as alice@looking_glass either, since these accounts belong to different domains, wonderland and looking_glass.

The accounts registered in the genesis block are just new accounts. As we said above, the genesis account is determined in the peer configuration. However, you can use the matching signature for the genesis account and for a new account in the genesis block. Since the genesis account only has privileges during the genesis round, it won't be a security issue.

You can generate the default genesis block or create a custom one.

If you need to recommit a genesis block, remove the previously stored blocks, then restart the Docker container. The new genesis block will be automatically recommited upon container restart.

Generation

You can add various instructions to the genesis block, such as registering new accounts or assets, as well as minting assets. You can also register permission tokens and roles, as well as grant them to the registered accounts.

Generate default genesis block

You can use kagami to generate the default genesis block:

  • Generate a genesis block in JSON format:

    bash
    kagami genesis
    
  • Generate a genesis block in JSON format and write the output to the specified file:

    bash
    kagami genesis > genesis.json
    
  • Generate a synthetic genesis block in JSON format and write the n domains, m accounts per domain and p assets per domain:

    bash
    kagami genesis --synthetic --domains n --accounts-per-domain m --assets-per-domain p
    

The genesis block should be located in configs/peer/genesis.json.

Configuration

As we already explained, genesis account is specified in the peer configuration file, configs/peer/config.json. You can use the same configuration file to fine-tune other genesis block configurations.