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
{
"chain": "00000000-0000-0000-0000-000000000000",
"executor": "executor.wasm",
"parameters": {
"sumeragi": {
"block_time_ms": 2000,
"commit_time_ms": 4000,
"max_clock_drift_ms": 1000
},
"block": {
"max_transactions": 512
},
"transaction": {
"max_instructions": 4096,
"smart_contract_size": 4194304
},
"executor": {
"fuel": 55000000,
"memory": 55000000
},
"smart_contract": {
"fuel": 55000000,
"memory": 55000000
}
},
"instructions": [
{
"Register": {
"Domain": {
"id": "system",
"logo": null,
"metadata": {}
}
}
},
{
"Register": {
"Account": {
"id": "ed0120D8B64D62FD8E09B9F29FE04D9C63E312EFB1CB29F1BF6AF00EBC263007AE75F7@system",
"metadata": {}
}
}
},
{
"Grant": {
"Permission": {
"object": {
"name": "CanRegisterAnyTrigger",
"payload": null
},
"destination": "ed0120D8B64D62FD8E09B9F29FE04D9C63E312EFB1CB29F1BF6AF00EBC263007AE75F7@system"
}
}
},
{
"Grant": {
"Permission": {
"object": {
"name": "CanUnregisterAnyTrigger",
"payload": null
},
"destination": "ed0120D8B64D62FD8E09B9F29FE04D9C63E312EFB1CB29F1BF6AF00EBC263007AE75F7@system"
}
}
},
{
"Register": {
"Domain": {
"id": "wonderland",
"logo": null,
"metadata": {
"key": "value"
}
}
}
},
{
"Register": {
"Account": {
"id": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland",
"metadata": {
"key": "value"
}
}
}
},
{
"Register": {
"Account": {
"id": "ed012004FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016@wonderland",
"metadata": {
"key": "value"
}
}
}
},
{
"Register": {
"AssetDefinition": {
"id": "rose#wonderland",
"type": "Numeric",
"mintable": "Infinitely",
"logo": null,
"metadata": {}
}
}
},
{
"Register": {
"Domain": {
"id": "garden_of_live_flowers",
"logo": null,
"metadata": {}
}
}
},
{
"Register": {
"Account": {
"id": "ed0120E9F632D3034BAB6BB26D92AC8FD93EF878D9C5E69E01B61B4C47101884EE2F99@garden_of_live_flowers",
"metadata": {}
}
}
},
{
"Register": {
"AssetDefinition": {
"id": "cabbage#garden_of_live_flowers",
"type": "Numeric",
"mintable": "Infinitely",
"logo": null,
"metadata": {}
}
}
},
{
"Mint": {
"Asset": {
"object": "13",
"destination": "rose##ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
}
}
},
{
"Mint": {
"Asset": {
"object": "44",
"destination": "cabbage#garden_of_live_flowers#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
}
}
},
{
"Transfer": {
"AssetDefinition": {
"source": "ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4@genesis",
"object": "rose#wonderland",
"destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
}
}
},
{
"Transfer": {
"Domain": {
"source": "ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4@genesis",
"object": "wonderland",
"destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
}
}
},
{
"Grant": {
"Permission": {
"object": {
"name": "CanSetParameters",
"payload": null
},
"destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
}
}
},
{
"Grant": {
"Permission": {
"object": {
"name": "CanRegisterDomain",
"payload": null
},
"destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
}
}
}
],
"wasm_dir": "libs",
"wasm_triggers": [
{
"id": "multisig_domains",
"action": {
"executable": "multisig_domains.wasm",
"repeats": "Indefinitely",
"authority": "ed0120D8B64D62FD8E09B9F29FE04D9C63E312EFB1CB29F1BF6AF00EBC263007AE75F7@system",
"filter": {
"Data": {
"Domain": {
"id_matcher": null,
"event_set": [
"Created",
"OwnerChanged"
]
}
}
}
}
},
{
"id": "multisig_accounts_wonderland",
"action": {
"executable": "multisig_accounts.wasm",
"repeats": "Indefinitely",
"authority": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland",
"filter": {
"ExecuteTrigger": {
"trigger_id": "multisig_accounts_wonderland",
"authority": null
}
}
}
}
],
"topology": []
}
The genesis account is specified in the genesis
section of the peer configuration file. 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 andp
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
.