Modify customSpec.json

you have to complete these before modifying the customSpec.json

this is what your created customSpec.json file should look like before you make the changes:

when you open this file, this is what you will see at the top:

customSpec.json

we will modify the first portion

replace the first three lines with the configuration below:

replace the 210124 with the date and version of your customSpec.json

replace the aura keys with the 1st two set of keys you generated

replace aura 1 with your 1st set of key

you will see that aura ONE is replaced 3 times

aura TWO appears 45 times.

Replace the grandpa key with grandpa 1 and grandpa 2

replace AURA THREE with the new key number 3 (appear 1 time)

repeat the process for AURA FOUR

remove the rest of the keys

it is not critical but i usually like to replace the number with a whole number. this number is not used in our process but it does show up in polkadotjs so its nice to have a whole number 😄

the revised customSpec.json will have only four keys. see sample here:

Screenshot of first part of revised customSpec.json

the new customSpec.json with the trusted nodes will look like this:

customSpec.json with trusted nodes

you can now transfer the new customSpec.json file back into your instance using Filezilla

To verify that your customSpec.json has been uploaded properly, go to your console terminal and verify as follows:

you will see that the header portion is showing the updated information on customSpec.json

at this point, you can now convert the customSpec.json file to a raw format.

Convert the chain specification to raw format

After you prepare a chain specification with the validator information, you must convert it into a raw specification format before it can be used. The raw chain specification includes the same information as the unconverted specification. However, the raw chain specification also contains encoded storage keys that the node uses to reference the data in its local storage. Distributing a raw chain specification ensures that each node stores the data using the proper storage keys.

To convert a chain specification to use the raw format:

  1. Open a terminal shell on your computer.

  2. Change to the root directory where you compiled the Substrate node template.

  3. Convert the customSpec.json chain specification to the raw format with the file name customSpecRaw.json by running the following command:

To modify the customSpec.json,

Create a custom chain specification

After you generate the keys to use with your blockchain, you are ready to create a custom chain specification using those key pairs then share your custom chain specification with trusted network participants called validators.

To enable others to participate in your blockchain network, ensure that they generate their own keys. After you collect the keys for network participants, you can create a custom chain specification to replace the local chain specification.

For simplicity, the custom chain specification you create in this tutorial is a modified version of the local chain specification that illustrates how to create a two-node network. You can follow the same steps to add more nodes to the network if you have the required keys.

Modify the local chain specification

Instead of writing a completely new chain specification, you can modify the predefined local chain specification.

To create a new chain specification based on the local specification:

  1. Open a terminal shell on your computer.

  2. Change to the root directory where you compiled the Substrate node template.

  3. Export the local chain specification to a file named customSpec.json by running the following command:

    If you open the customSpec.json file in a text editor, you would see that it contains several fields. One of those fields is the WebAssembly (Wasm) binary for the runtime you built using the cargo build --release command. Because the WebAssembly (Wasm) binary is a large blob, you can preview the first and last few lines to see the fields you need to change.

  4. Preview the first few fields in the customSpec.json file by running the following command:

    The command displays the first fields from the file. For example:

  5. Preview the last fields in the customSpec.json file by running the following command:

    This command displays the last sections following the Wasm binary field, including the details for several of the pallets—such as the sudo and balances pallets—that are used in the runtime.

  6. Open the customSpec.json file in a text editor.

  7. Modify the name field to identify this chain specification as a custom chain specification.

    For example:

  8. Modify aura field to specify the nodes with the authority to create blocks by adding the Sr25519 SS58 address keys for each network participant.

  9. Modify the grandpa field to specify the nodes with the authority to finalize blocks by adding the Ed25519 SS58 address keys for each network participant.

    Note that there are two data values for the authorities field in the grandpa section. The first value is the address key. The second value is used to support weighted votes. In this example, each validator has a weight of 1 vote.

  10. Save your changes and close the file.

Last updated