Search code examples
substrate

How to create an account programmatically with Substrate?


Besides my substrate network, I want to create a wallet app. When the user opens it, the account on the network should be created programmatically, I figured out how to generate mnemonic and the key pair, but how do i put my keypair on the blockchain? Can I just send tokens to a public key that never been seen on the network?


Solution

  • Can I just send tokens to a public key that never been seen on the network?

    Yes. If you use AccountId32 as account id, every account is just a 32 byte long public key.

    Even when an account falls below existential deposit, the account "stays", only all associated data is reaped. Next time you send funds to this account, it will be usable again.