# Create Account and Wallet

# Introduction

In Bytom, account is an abstract entity that can determine the ownership of assets on blockchain by tracking control programs or addresses. The control program or address will appear in the output of each transaction. Among them, control program defines a series of requirements that must be met when spending this output; the address is generated by hash computing by the public key or script. Both the control program and the address can be used as the output address of a transaction. When the next transaction cost is output, the private key matching the public key of the output address is required to sign.

There can be many account entities on localhost, which are not stored on the blockchain, but only exist locally. Only the control program or address created in the account will appear on the blockchain. However, when a transaction is being processed, local account data can provide queries that are more powerful and easier for users to understand.

# Create private key

Create private key before creating a wallet

// Request
curl -X POST create-key -d '{"alias": "alice", "password": "123456", "language": "en"}'

// Result
{
  "status": "success",
  "data": {
    "alias": "alice",
    "xpub": "6f9d945cd03cce033f4a2a9fd5659d3ddfa58e2d32f8c711baca0de0aae83ff6d67f4f4e53f3ff0b3c11bac2a11123c26c7c32e0478e6cf802ca1109941bb45b",
    "file": "/home/yang/.bytom/keystore/UTC--2018-10-10T07-09-17.509894697Z--341695b9-9223-470c-a26d-bea210f8e1bb",
    "mnemonic": "price put soldier kitten beef garlic release burden symptom jump purity flower"
  }
}

# Create an account

Create a wallet account, transfer xpub in which is generated in the previous step as a parameter

curl -X POST create-account -d '{"root_xpubs":["6f9d945cd03cce033f4a2a9fd5659d3ddfa58e2d32f8c711baca0de0aae83ff6d67f4f4e53f3ff0b3c11bac2a11123c26c7c32e0478e6cf802ca1109941bb45b"],"quorum":1,"alias":"alice"}'

// Result
{
  "status": "success",
  "data": {
    "id": "4b5d460c-7773-4b6e-94ee-4d074df31729",
    "alias": "alice",
    "xpubs": [
 "6f9d945cd03cce033f4a2a9fd5659d3ddfa58e2d32f8c711baca0de0aae83ff6d67f4f4e53f3ff0b3c11bac2a11123c26c7c32e0478e6cf802ca1109941bb45b"
    ],
    "quorum": 1,
    "key_index": 1,
    "derive_rule": 1
  }
}

quorum represents the number of signatures, single-signature is set to 1, and multi-signature is set to be more than 1.

# Create address

After the account is created, you can create an address, you need to input the account alias and ID

curl -X POST create-account-receiver -d '{"account_alias": "alice", "account_id": "4b5d460c-7773-4b6e-94ee-4d074df31729"}'

{
  "status": "success",
  "data": {
    "control_program": "0014b649dc914cb95a2a263604319b00fc3995c06cd4",
    "address": "bn1qkeyaey2vh9dz5f3kqscekq8u8x2uqmx5h6p06c"
  }
}

You can use it to collect payments after the address is created

Last Updated: 8/27/2021, 6:07:22 PM