Skip to content

Creating New Accounts

Accounts are necessary to interact with the blockchain and are composed of a unique account_name and a set of Cryptographic keys.

In order to prevent indiscriminate account creation, new accounts can only be registered by an existing account which can charge for that service.

Accounts can be created using DecentGo and other tools, such as the CLI_wallet.

DecentGo can be used to create an account without charge or needing to know someone else who can do it for you and is provided as a service by Decent to help new users set up their first accounts.


Creating Your Very First Account

As was mentioned in the text above, to create a new account, which is supposed to be your very first account, there is a need to register it using an already existing account in DCore Blockchain. To proceed this way, please provide only your account_name and public_key's to an existing account/a registrar, which will register you. To ensure safety of your account, please do not provide your brain_key or private_key to anyone. Proceed with next steps using the following methods to get your brain_key, private_key and public_key. These together with account_name, as a set, define your account.

Generation of the Brain Key

Warning

Brain key is the ONLY way to recover your account should you forget your login credentials.

Method definition:

The Wallet API method suggest_brain_key generates a new brain_key and corresponding private key and public key as an example to use for creating your account.

  • brain_key - a long passphrase and consists of randomly chosen 16 words that provide enough entropy to generate a private_key.
  • Suggested brain_key - a string that should be easy to write down and/or memorize.
brain_key_info suggest_brain_key();

Returned value:

  • A suggested brain_key, private key in WIF (Wallet Import Format) and public key.

Call - brain_key:

suggest_brain_key

Response:

suggest_brain_key
{
  "brain_priv_key": "SMUG NAPHTHA OCHER WHELM SOVCERY PIGLY GUDGET LOTA SELF LATEX GNOSTIC GIFT IDANT THEYLL SPLOTCH FIXATE",
  "wif_priv_key": "9JBQVbjNkjRqT4GZJpdmbt7AS5ji8VfN42cfFQ9v5PZpRyVub8f",
  "pub_key": "DCT9SFcioQFYXnNHNSAEcLb5o5EovrhjPk4SMbYnag6t6VhwuvMAc"
}

Another way how to generate new keys is to use keys_generator program, which allows offline keys generation. The program and the method above produce the same response.

The returned pub_key will be used for creating an account in the DCore using the register_account method about which the next section is written.

The wif_priv_key will be used for importing this newly created account to the Wallet and more information you can find in the section following registration of the account named Import an account to the CLI Wallet.

Registering Your Account Using Generated Public Keys

Important

Please, take into consideration an account name you will use as the name of your account name must follow RFC 1035 grammar (e.g. should be at least 5 characters long, has to start with letter, all letters are lowercase, only dots and hyphens are allowed from non-alphanumeric characters, and so on).

As a kindly reminder, the following method will be used by a registrar. In other words, the account, which is going to register your first account and pay registration fee.

Method definition:

register_account - Registers a third party's account on the DCore Blockchain. This function is used to register an account for which you (as a registrar) do not own the private keys and which has not yet existed in DCore Blockchain. When acting as a registrar, an end user will generate their own private keys and send you the public keys. The registrar will use the method to register an account on behalf of the end user.

signed_transaction register_account(string name,
                                    public_key_type owner,
                                    public_key_type active,
                                    string registrar_account,
                                    bool broadcast = false);

Parameters:

  • name - The name of the account, must be unique on the DCore Blockchain.
  • owner - The owner key for the new account. This key represents absolute control over the account. Generally, the only time the owner key is required is to update the account keys.
  • active - The active key for the new account. The active key represents the hot key of the account. This key has control over nearly all operations the account may perform.
  • registrar_account - The account which will pay the fee to register the user and sign transaction.
  • broadcast - When its value is set to true then the transaction will be broadcast on the network.

Important

Besides the owner and active key, an account also uses memo_key. The memo key is used to encrypt/decrypt transaction memos. In the case of this method, memo_key will be the same as active_key.

For the sake of simplicity, we use the same key for owner and active keys in the example below. Although such a configuration is valid, it is considered less secure.

We would also like to mention that the account keys can be changed later.

Returned value:

  • The signed transaction registering the account.

Call - register_account:

register_account accountname DCT8SFcioQFYXnNHNSAEcLb5o5EovrhjPk4SMbYnag6t6VhwuvMAc \
DCT8SFcioQFYXnNHNSAEcLb5o5EovrhjPk4SMbYnag6t6VhwuvMAc decent true

Response:

register_account accountname DCT9SFcioQFYXnNHNSAEcLb5o5EovrhjPk4SMbYnag6t6VhwuvMAc DCT9SFcioQFYXnNHNSAEcLb5o5EovrhjPk4SMbYnag6t6VhwuvMAc decent true
{
  "ref_block_num": 24034,
  "ref_block_prefix": 2856729761,
  "expiration": "2017-11-13T13:11:10",
  "operations": [[
      1,{
        "fee": {
          "amount": 500000,
          "asset_id": "1.3.0"
          },
        "registrar": "1.2.15",
          "name": "accountname",
          "owner": {
            "weight_threshold": 1,
            "account_auths": [],
            "key_auths": [[
                "DCT9SFcioQFYXnNHNSAEcLb5o5EovrhjPk4SMbYnag6t6VhwuvMAc",
                1
              ]
            ]
          },
        "active": {
              "weight_threshold": 1,
              "account_auths": [],
              "key_auths": [[
                  "DCT9SFcioQFYXnNHNSAEcLb5o5EovrhjPk4SMbYnag6t6VhwuvMAc",
                  1
                ]
              ]
            },
            "options": {
              "memo_key": "DCT9SFcioQFYXnNHNSAEcLb5o5EovrhjPk4SMbYnag6t6VhwuvMAc",
              "voting_account": "1.2.3",
              "num_miner": 0,
              "votes": [],
              "extensions": [],
              "allow_subscription": false,
              "price_per_subscribe": {
                "amount": 0,
                "asset_id": "1.3.0"
              },
              "subscription_period": 0
            },
            "extensions": {}
          }
        ]
      ],
      "extensions": [],
      "signatures": [
        "1f4d1caa9fffa8c7723169bcce6de18ca1acc306b60e07e9efd0906e8fdb02f5cc69961f59271c89b900917d764462157110ac4092e0f767233db9fd31ea69aaae"
      ]
  }

Import an Account to CLI Wallet

After your account was registered on the blockchain, to use it within the CLI Wallet you need to import the account. The next method will provide needed action.

Method definition:

import_key - Imports the private key for an existing account.

bool import_key(string account_name_or_id,
                string wif_key);

Parameters:

  • account_name_or_id - The account owning the key.
  • wif_key - The private key in WIF format.

Returned value:

  • true if the key belongs to the account.

Call - import_key:

import_key decent 9JBQVbjNkjRqT4GZJpdmbt7AS5ji8VfN42cfFQ9v5PZpRyVub8f

Response:

import_key decent 9JBQVbjNkjRqT4GZJpdmbt7AS5ji8VfN42cfFQ9v5PZpRyVub8f
true

Create a New Account with Automatic Import to CLI Wallet

In this section we will present how to create another account via your existing account. The provided method consists of an account creation and its import to the CLI Wallet, as well.

Method definition:

create_account_with_brain_key() - Requires you to specify a brain key.

signed_transaction
create_account_with_brain_key(string brain_key,
                              string account_name,
                              string registrar_account,
                              bool broadcast = false);

Parameters:

  • string brain_key - The brain key used for generating the account's private keys.
  • string account_name - The name of the account, must be unique on the blockchain and contains at least 5 characters.
  • string registrar_account - The account which will pay the fee to register the user.
  • broadcast - When its value is set to true then the transaction will be broadcast on the network.

Call - create_account_with_brain_key:

create_account_with_brain_key \
"SMUG NAPHTHA OCHER WHELM SOVCERY PIGLY GUDGET LOTA SELF LATEX GNOSTIC GIFT IDANT THEYLL SPLOTCH FIXATE" \
accountname decent true

Response:

create_account_with_brain_key "SMUG NAPHTHA OCHER WHELM SOVCERY PIGLY GUDGET LOTA SELF LATEX GNOSTIC GIFT IDANT THEYLL SPLOTCH FIXATE" accountname decent true
{
  "ref_block_num": 32575,
  "ref_block_prefix": 1149709988,
  "expiration": "2017-12-21T14:50:25",
  "operations": [[
      1,{
        "fee": {
          "amount": 500000,
          "asset_id": "1.3.0"
        },
        "registrar": "1.2.15",
        "name": "accountname",
        "owner": {
          "weight_threshold": 1,
          "account_auths": [],
          "key_auths": [[
              "DCT8NC1kNjEeqRp8SnEPQWtpeCLoJRuquH5jHtE78NNTthSi6t2uX",
              1
            ]
          ]
        },
        "active": {
          "weight_threshold": 1,
          "account_auths": [],
          "key_auths": [[
              "DCT71c3ord9nDJuVipGgZMcALLzya9DRqu2ms9dpyn4pv5wTMMNRx",
              1
            ]
          ]
        },
        "options": {
          "memo_key": "DCT7ZdBtDtrAXCidXHPNrMyagegBLN8ruv6EmJ5EYdq6rYJLPztuH",
          "voting_account": "1.2.3",
          "num_miner": 0,
          "votes": [],
          "extensions": [],
          "allow_subscription": false,
          "price_per_subscribe": {
            "amount": 0,
            "asset_id": "1.3.0"
          },
          "subscription_period": 0
        },
        "extensions": {}
      }
    ]
  ],
  "extensions": [],
  "signatures": [
    "20124f6d942d7eaf555c7c3bc420d35b877123ef63d1440edc904b5ae46c17df1d53dc433a3a1785ae8f9dba7a366639be140ecf0278a369100744189eaadb5989"
  ]
}

Info

As you can see in the example above, this method deterministically derives different active_key and memo_key from owner_key.