11

When creating a blockchain node, I noticed that there are predefined accounts with a bunch of balances. Does everyone on my blockchain have access to these accounts? And how do I remove them?

2 Answers 2

10

The Balances pallet supports a Genesis Configuration which allows you to specify a set of accounts and balances that should exist at the genesis of your chain.

For a developer chain (using --dev), most nodes are configured to give genesis balances to a set of default accounts like Alice, Bob, Charlie, Dave, Eve, and Ferdie.

These accounts are all "well known" and has a documented private key:

bottom drive obey lake curtain smoke basket hold race lonely fit walk

So if you want to generate the private key pair for Alice, you would would add //Alice as a hard derivation key to the seed above:

bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice

To remove these genesis balances from your developer chain, you can modify the testnet_genesis in your project, however note that without genesis balances to any of your users, your chain may become locked out, since no one will be able to submit transactions without paying fees.

5

In node/src/chain_spec.rs you will find the functions local_testnet_config and development_config which contains lines like these

move || {
        testnet_genesis(
            wasm_binary,
            // Initial PoA authorities
            vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")],
            // Sudo account
            get_account_id_from_seed::<sr25519::Public>("Alice"),
            // Pre-funded accounts
            vec![
                get_account_id_from_seed::<sr25519::Public>("Alice"),
                get_account_id_from_seed::<sr25519::Public>("Bob"),
                get_account_id_from_seed::<sr25519::Public>("Charlie"),
                get_account_id_from_seed::<sr25519::Public>("Dave"),
                get_account_id_from_seed::<sr25519::Public>("Eve"),
                get_account_id_from_seed::<sr25519::Public>("Ferdie"),
                get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
                get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
                get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
                get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
                get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
                get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
            ],
            true,
        )
    },

Modify this file to create the preseeded and sudo keys you want to use

To get the private keys for //Alice and //Bob it is possible to use subkey command

subkey inspect //Alice

and it returns:

Secret Key URI `//Alice` is account:
  Secret seed:       0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a
  Public key (hex):  0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
  Public key (SS58): 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
  Account ID:        0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
  SS58 Address:      5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Feb 9, 2022 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.