Generate Account

Overview

An address is the public part of an account. The private part is the key used to access and control this address. An account is a pair of public and private parts.

There are several ways to generate an account.

Definition

  • The mnemonic seed is 12 (default), 15, 18, 21, and 24 words. You don’t need to remember these as you will download your account to file, and can be restored lately or used in a wallet that supports Polkadot accounts.

  • Keypair crypto type is preferred to use sr25519. Ed25519 is an older cryptography to generate keys. It was used more in the past and for validator sets mostly.

  • Keyring provides other functions, such as creating account from JSON, backup accounts...

Generate account

Diagram

Description

Generate mnemonic

The main function of a mnemonic generation on load is mnemonicGenerate() which is based on top of bip39Generate() which is Javascript wrapper on top of bip39.rs.

Then we will initialize keyring().This is the core abstraction around key management in our tool to manage various keypairs. To utilize keyring, we will use the function addFromMnemonic() with a generated mnemonic, meta, and our keyringType, which is, in this case, sr25519. You find mnemonicValidate() which checksums your mnemonic is the right one.

Create account

SS58 is a simple address format designed for Glitch-based chains. It is heavily based on Bitcoin’s Base-58-check format with a few alterations. We will use getPair() on top of the keyring. It will retrieve an account keyring pair from the Keyring Pair Dictionary, given an account address.

For verifying signatures, we need publicKey. We will get it the same using getPair() but also need to use Uint8Array to Hexadecimal function, using u8aToHex()

Existential deposit

Existential deposit= 0,0005 GLCH

Glitch uses an existential deposit (ED) to prevent dust accounts from bloating chain state. If an account drops below the ED, it will be reaped, i.e. completely removed from storage and the nonce reset. Likewise, sending a transfer with a value below the ED to a new account will fail. Custodial wallets should set a minimum withdrawal amount greater than the ED to guarantee successful withdrawals.

When making a tx to transfer tokens from one account to another:

  • Sending account: If the remaining amount is smaller than ED=0,0005 GLCH → Tx fail.

  • Recipient account: If this account is a new account with balance=0 and the received amount is smaller than ED=0,0005 GLCH → Tx fail.

Last updated