Preparation: Generate the Collator's Address

Collator's address can be input with Magnet stack and writeen into default configation file for your parachain template. You can manually define the collator's address by specifying a custom key pair when starting the node.

To generate a key pair using the Substrate CLI, you can use the subkey utility that comes with Substrate. Here’s how you can do it:

Steps to Generate a Key Pair

  1. Install Subkey (if not already installed):

    • If you have Substrate installed, you already have subkey. If not, you can install it using the following command:

      cargo install --force subkey
  2. Generate a Key Pair:

    • Run the following command to generate a new key pair:

      subkey generate
    • This will output something like:

      Secret phrase `seed phrase here` is account:
      Secret seed:      0x...
      Public key (hex): 0x...
      Account ID:       0x...
      SS58 Address:     5...
    • The Secret phrase is your mnemonic seed phrase, which you can use to regenerate the keys. The SS58 Address is the public address derived from the public key.

  3. Generate a Key Pair for a Specific Network:

    • If you want to generate a key pair for a specific network like Polkadot or Kusama, you can add the network option:

      subkey generate --network polkadot
    • This ensures that the generated address is compatible with the specific network’s format.

  4. Specify a Custom Seed Phrase:

    • If you want to generate a key pair from a specific seed phrase, you can use:

      subkey inspect "<your-seed-phrase>"
    • This will output the corresponding public key and address for that seed phrase.

  5. Get a Key Pair for Specific Cryptography Type:

    • Subkey supports various cryptography types, such as sr25519 (default), ed25519, and ecdsa. You can specify one using:

      subkey generate --scheme sr25519

Example Output

Secret phrase `crisp judge talk palm tent confirm salad lunar stomach inspire brain jaguar` is account:
  Secret seed:      0x9245...f66a
  Public key (hex): 0x4b9a...d019
  Account ID:       0x4b9a...d019
  SS58 Address:     5EYCAe5LC5G...

Saving the Keys

  • You can save the secret seed and public key to a file for later use. Ensure that the seed phrase or secret seed is stored securely, as it provides full control over the corresponding account.

By following these steps, you can generate key pairs for your Substrate-based projects or networks, which you can use for collators, validators, or any other accounts on the network.

Last updated