> For the complete documentation index, see [llms.txt](https://ground-x.gitbook.io/kas-docs-dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ground-x.gitbook.io/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/getting-started/account.md).

# Create Klaytn Account

This page introduces how to create Klaytn accounts used in KAS.

## What is Klaytn Account? <a href="#getting-started-account-what-is-account" id="getting-started-account-what-is-account"></a>

For a blockchain application developed by a user, the application will send transactions to the blockchain. The host sending transactions to the blockchain is the "Account," while the user's account is denoted by [EOA](https://docs.klaytn.com/klaytn/design/accounts#klaytn-account-types) in Klaytn. A Klaytn account is required for sending transactions to the platform using Wallet API or searching for KLAY or token transaction records through the Token History API.

{% hint style="info" %}
A KAS account is created through KAS membership, while a Klaytn account must be created on the KAS Console.\
For details on the transaction, please visit [here](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/tutorial/wallet-transaction-api.md).
{% endhint %}

For inquires about this document or KAS, please visit [Developer Forum](https://forum.klaytn.com/c/kas/kasen/27).

## Account, Fee-payer Account, Operator Account <a href="#getting-started-account-types" id="getting-started-account-types"></a>

Klaytn accounts include all accounts for storing, sending, and receiving KLAY (externally-owned account, EOA), smart contract accounts created when deploying smart contracts, etc.

KAS offers several account types according to account roles for your convenience.

* **Account**: The host who sends transactions to Klaytn
  * [Send KLAY](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/tutorial/wallet-transaction-api/wallet-transaction-klay.md)
  * [Deploy Smart Contract](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/tutorial/wallet-transaction-api/wallet-transaction-contract-deploy.md)
  * [Execute Smart Contract](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/tutorial/wallet-transaction-api/wallet-transaction-contract-execute.md)
  * [Change AccountKey](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/tutorial/wallet-transaction-api/wallet-transaction-update.md)
  * [Send Other Transactions](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/tutorial/wallet-transaction-api/wallet-transaction-else.md)
* **Fee-payer Account**: The host paying transaction fees for Accounts that send transactions to Klaytn
  * [Send KLAY with Fee-Delegation](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/tutorial/wallet-transaction-api/wallet-transaction-klay.md#tutorial-wallet-transaction-klay-fd)
  * [Deploy Smart Contract with Fee-Delegation](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/tutorial/wallet-transaction-api/wallet-transaction-contract-deploy.md#tutorial-wallet-transaction-contract-deploy-fd)
  * [Execute Smart Contract with Fee-Delegation](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/tutorial/wallet-transaction-api/wallet-transaction-contract-execute.md#tutorial-wallet-transaction-contract-execute-fd)
  * [Change AccountKey with Fee-Delegation](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/tutorial/wallet-transaction-api/wallet-transaction-update.md#tutorial-wallet-transaction-update-fd)
  * [Anchor Data with Fee-Delegation](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/tutorial/wallet-transaction-api/wallet-transaction-anchoring.md#tutorial-wallet-transaction-anchoring-fd)
* **Operator**: The host that anchors the service chain data to the Klaytn main chain
  * [Anchor Data](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/tutorial/anchor-api.md#tutorial-anchor-anchoring)

For inquires about this document or KAS, please visit [Developer Forum](https://forum.klaytn.com/c/kas/kasen/27).

## Account Pool <a href="#getting-started-account-accountpool" id="getting-started-account-accountpool"></a>

A KAS account may contain several Klaytn accounts. KAS provides account pool for easy and convenient management of all Klaytn accounts using just one KAS account. Individual types of Klaytn accounts also have their own account pools, and one KAS account may create and operate multiple storages.

KAS provides the following account pool types for your convenience according to account roles.

* **Account Pool**: A space for managing regular Klaytn accounts
* **Fee-payer Pool**: A space for managing fee-payer accounts

For inquires about this document or KAS, please visit [Developer Forum](https://forum.klaytn.com/c/kas/kasen/27).

## Create Klaytn Account <a href="#getting-started-account-create" id="getting-started-account-create"></a>

### Create Account Pool <a href="#getting-started-account-create-accountpool" id="getting-started-account-create-accountpool"></a>

KAS provides account pool for managing several Klaytn accounts. To use this, a user must first create account pool on the KAS Console and then create a new KAS Console account in the account pool created using the account creation API. account pool must be created first to use and manage the personal account pool instead of resorting to the default account pool.

#### Default Account Pool

The default account pool is the account pool provided to you when you do not choose your own account pool in calling KAS API. If you didn't feed the KRN of your own account pool into `x-krn` in API Request header, then the Klaytn account in the default account pool is used for calling this API. All the default account pools are tagged with `DEFAULT` as you look at these on KAS Console - Service - Wallet - Account Pools menu.

The first account pool you create is automatically designated as the default account pool. For example, if you have created an account pool named `A` in KAS Console and you didn't specify any account pool in calling API, the Klaytn account stored in this `A` account pool is automatically used in calling API afterwards. When you haven't created any account pool and you try to call API that creates a Klaytn account, KAS automatically create the default account pool and push this newly created Klaytn account into this default account pool for you.

{% hint style="info" %}
Feed the KRN of other account pool to `x-krn` if you want to call API with Klaytn account stored in some other account pool.
{% endhint %}

#### KAS Console > Service > Wallet > Account Pools

Click the \[Create] button under the **KAS Console** > **Service** > **Wallet** > **Account Pools** menu. And then click on the button to display the screen for creating Klaytn account pools.

![Service > Wallet > Account Pools](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2F8f36c28d56da96650f46548ecd94bbabdbe53e13.png?generation=1630896824231854\&alt=media)

#### Create Account Pool

Create a Klaytn account pool, and it must have a different name from other account pools on the current KAS account.

![Create Account Pool](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2F97e167aa731b66b1fcdc611152aae109d07d06b7.png?generation=1630896824951485\&alt=media)

#### Check the Account Pool

Once the account pool is created, check the account pool in the account pool list.

{% hint style="info" %}
If you put KRN which is obtained from account pool into `x-krn` in API request header, you would call this API with the Klaytn account stored in this account pool.
{% endhint %}

![Created Account Pool](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2Feb4e026568eae440aee5941c2a29963ad452d6bb.png?generation=1630896824399813\&alt=media)

For inquires about this document or KAS, please visit [Developer Forum](https://forum.klaytn.com/c/kas/kasen/27).

### Create Account <a href="#getting-started-account-create-account" id="getting-started-account-create-account"></a>

#### Create in Console

Select any one of the account pools created above. On the screen of the selected account pool, click \[Create Account] to create an account.

![Creating an account in the selected account pool](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2Fc87591c725302c7ee289118d4ca0191c8b3961ec.png?generation=1630896824499215\&alt=media)

#### API Request

Call the Klaytn account creation API as follows. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

An [API authentication key](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/basics/api.md#basics-api-key) can be created on KAS Console - Security - Credential menu, and the authentication password (`Secret AccessKey`) and `Authorization` can only be checked once **upon their creation.** Therefore, it is necessary to **copy or download Secret AccessKey and Authorization to a safe location** for proper and safe management after its creation. `Authorization` (e.g., `Basic S0FTS1A2WkRaSjh...`), which can be checked after creating an authentication key, refers to a value encoded using the AccessKey ID and Secret AccessKey through the basic authentication method and used for the call header when calling APIs.

A KAS API Authentication Key (API Auth Key) provides access to all KAS services and all the rights to a Klaytn account which was created by calling Wallet API via this API Auth Key. The rights here include accessing and transferring all the assets (KLAY, etc.) of or sending a [transaction](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/tutorial/wallet-transaction-api.md) from a Klaytn account. If you shared your API Auth Key with any unauthorized personnel, your Klaytn account could be compromised and might cause unwanted transaction execution.

{% hint style="danger" %}
DO NOT share your API Auth Key (Secret AccessKey or Authorization) with any unauthorized personnel.\
DO PUT efforts necessary to keep your API Auth Key safe for the security of your KAS/Klaytn account.
{% endhint %}

{% tabs %}
{% tab title="curl" %}

```javascript
//An example of using the default account pool of KAS with the x-krn header parameter is omitted
curl --location --request POST "https://wallet-api.klaytnapi.com/v2/account" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}"

//An example of using the account pool created above with the x-krn header parameter is included
curl --location --request POST "https://wallet-api.klaytnapi.com/v2/account" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}"
--header "x-krn: krn:1001:wallet:6698d79e-78ee-439a-815d-f293ec6ae736:account-pool:ap1"
```

{% endtab %}

{% tab title="javascript" %}

```javascript
const result = await caver.kas.wallet.createAccount()
```

{% endtab %}

{% tab title="java" %}

```java
Account account = caver.kas.wallet.createAccount();
System.out.println(account);
```

{% endtab %}
{% endtabs %}

#### API Response

Here is the response of the Klaytn account creation API.

{% tabs %}
{% tab title="curl" %}

```javascript
//Example of a response when creating an account in the KAS default account pool
{
  "address": "0xa809284C83b901eD106Aba4Ccda14628Af128e14",
  "chainId": 1001,
  "createdAt": 1599187293,
  "keyId": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default:0x4cbbcb974e32a7960e1b356edf60087613101919ed83199f12e872cba068a50f",
  "krn": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default",
  "publicKey": "0x04cdccfb99b2905561e3dd886687b429a004718f11b04914f17ce68fd3a0db46c598a45da85caa61fe84cb78a0f2eaa9983ec7b8805a93ef9428eb1350a8558237",
  "updatedAt": 1599187293
}

//Example of a response when creating an account in the account pool that you created
{
  "address": "0xa809284C83b901eD106Aba4Ccda14628Af128e14",
  "chainId": 1001,
  "createdAt": 1599187293,
  "keyId": "krn:1001:wallet:6698d79e-78ee-439a-815d-f293ec6ae736:account-pool:ap1:0x4cbbcb974e32a7960e1b356edf60087613101919ed83199f12e872cba068a50f",
  "krn": "krn:1001:wallet:6698d79e-78ee-439a-815d-f293ec6ae736:account-pool:ap1",
  "publicKey": "0x04cdccfb99b2905561e3dd886687b429a004718f11b04914f17ce68fd3a0db46c598a45da85caa61fe84cb78a0f2eaa9983ec7b8805a93ef9428eb1350a8558237",
  "updatedAt": 1599187293
}
```

{% endtab %}

{% tab title="javascript" %}

```javascript
Account {
  address: '0xC42cF87D75d3233de424cD68B0B6fE381aD83E98',
  chainId: 1001,
  createdAt: 1601876981,
  keyId: 'krn:1001:wallet:8e76d003-d6dd-4278-8d05-5172d8f010ca:account-pool:default:0x199647191a710a38496ed645eeec3b82d980dd635eebe236464ebc3c28f2d841',
  krn: 'krn:1001:wallet:8e76d003-d6dd-4278-8d05-5172d8f010ca:account-pool:default',
  publicKey: '0x04f86e01d9ec2f80cf47594c342aa1151a5b9cf95c3d0b8ba8613afa531ebdf7fe4b7c49c2b0d25be6491fe53b92bbb40f23f1f830ca50708f8fe2775f24e9c4ce',
  updatedAt: 1601876981
}
```

{% endtab %}

{% tab title="java" %}

```java
class Account {
    address: 0xE8785620772e6d5cddB4C71808C0EcF2FDEB4079
    chainId: 1001
    createdAt: 1602120333
    keyId: krn:1001:wallet:d5c346f5-bb80-4f45-9093-57e25205cdc8:account-pool:pool:0xa7b69c64336b0bc63481569cd81edaee81d61b35b4511d954dc534651eca75a3
    krn: krn:1001:wallet:d5c346f5-bb80-4f45-9093-57e25205cdc8:account-pool:pool
    publicKey: 0x04c5d9f0da5f39dcfb10fc386ce33853f6fbe0b75854433fd48af63af11ed889026d5b4f254637d21d8c03f9072065144529c0a54a36ed757b1893bad670d7dd0c
    updatedAt: 1602120333
    multiSigKeys: null
    threshold: null
}
```

{% endtab %}
{% endtabs %}

For details about this API, please visit [here](https://refs.klaytnapi.com/en/wallet/latest#operation/CreateAccount). For inquires about this document or KAS, please visit [Developer Forum](https://forum.klaytn.com/c/kas/kasen/27).

### Loading KLAY into Account <a href="#getting-started-account-account-faucet" id="getting-started-account-account-faucet"></a>

{% hint style="warning" %}
You can only receive KLAY on the testnet (Baobab). After you claim your KLAY from Faucet for a certain account, you have to wait 24 hours for the daily limit to reset.
{% endhint %}

#### Getting 5KLAY

You can load 5KLAY into your account by clicking on the battery icon next to the account address.

![Get 5KLAY for your account](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2F61aa79f6e333a7ca48234c77c7e8a8544d95647f.png?generation=1630896825133062\&alt=media)

For more information on this API, please refer to [here](https://refs.klaytnapi.com/en/wallet/latest#operation/CreateAccount). For inquiries on this document or on KAS in general, please visit [Klaytn Forum](https://forum.klaytn.com/c/kas/kasko/26).

## Create Fee-payer Account <a href="#getting-started-account-createfp" id="getting-started-account-createfp"></a>

### Create Fee-payer Pool <a href="#getting-started-account-createfp-fppool" id="getting-started-account-createfp-fppool"></a>

If you want to create the fee-payer account that pays the transaction fee for your other Klaytn accounts in KAS, you first have to create the fee-payer pool that manages those fee-payer accounts. You can create multiple fee-payer pools. After creating fee-payer pools in KAS Console, you need to select one to create a fee-payer account inside of it.

{% hint style="info" %}
For details of the fee delegation methods that KAS provides, please visit [here](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/basics/api.md#basics-api-fd).
{% endhint %}

#### KAS Console - Service - Wallet - Fee-payer Pools

Click the “Create” button under the KAS Console - Service - Wallet - Fee-payer Pools menu. Click the button to display the screen for creating fee-payer pools.

![Service - Wallet - Fee-payer Pools](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2Fb90ba38d965031d5afbd40bf6651f111c63882c4.png?generation=1630896825829485\&alt=media)

#### Create Fee-payer Pool

Create a fee-payer pool, and it must have a different name from other fee-payer pools on the current KAS account.

![Create Fee-payer Pool](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2F7f857da2d245852011e2324b7a75f366724cd073.png?generation=1630896829883371\&alt=media)

{% hint style="warning" %}
Fee-payer accounts must only be created on the KAS Console, according to this guide.\
If a fee-payer account is created through another KAS API, it will not be registered to a KAS fee-payer pool.
{% endhint %}

#### Check Fee-payer Pool

Once the fee-payer pool is created, verify the pool in the fee-payer pool list.

{% hint style="info" %}
KRN is used to call APIs for sending fee-delegated transactions.
{% endhint %}

![Check Fee-payer Pool](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2F7a00f13efe5bcf8fd659feec5847fb8a3686d303.png?generation=1630896824527101\&alt=media)

For inquires about this document or KAS, please visit [Developer Forum](https://forum.klaytn.com/c/kas/kasen/27).

### Create Fee-payer Account <a href="#getting-started-account-createfp-fp" id="getting-started-account-createfp-fp"></a>

Select one of the fee-payer pools to create a fee-payer account. Click a pool's KRN to display the "Details" screen of the fee-payer pool.

![List of Fee-payer Pools](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2F18bc8a152f5e8cd416c4c28540903cbcfeefe2ab.png?generation=1601881550956435\&alt=media)

![Details of a Fee-payer Pool](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2Fa13f2ede309967d3e90d400e4bbb3451b763e28d.png?generation=1629868866754667\&alt=media)

Click "Create Account" button to create the fee-payer account.

![Create Fee-payer Account in the Fee-payer Pool](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2Faf6220cb48cd11b8fec096c994714896aa09ca15.png?generation=1630896824333368\&alt=media)

Check the newly created fee-payer account on the Details screen under the fee-payer pool.

![Created Fee-payer Account](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2F7476680b15f798f93213ad5f059de0dabf99bd4b.png?generation=1630896829657880\&alt=media)

![Details of Created Fee-payer Account](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2Ffa8d2952f74a4e52176ebd763856708f37ec15dc.png?generation=1630896825111751\&alt=media)

For inquires about this document or KAS, please visit [Developer Forum](https://forum.klaytn.com/c/kas/kasen/27).

## Create Operator <a href="#getting-started-account-createop" id="getting-started-account-createop"></a>

#### KAS Console - Service - Anchor - Operators

Click the "Create" button on the KAS Console - Service - Anchor - Operators menu. Click the button to display the screen for creating operators as follows.

![Service - Anchor - Operators](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2F6ee2464d364f4207c8727cbba66f750d31eb3968.png?generation=1601881552096121\&alt=media)

#### Configure Transaction Fee Payments for Data Anchoring Transaction

For creating an operator on the KAS Console, set the account that would pay the anchoring transaction fee for data to be sent by the operator.

![Create Operator and Configure Anchoring Transaction Fee](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2F2ae66a563384ed11a3bb7bb3c9b11dc48cc1f1ad.png?generation=1601881551800508\&alt=media)

| Parameter         | Description                                                                                                            |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------- |
| feepayer          | User's fee-payer account address. Used when paying data anchoring transaction fees using user's own fee-payer account. |
| useOperator       | Whether the operator will pay the data anchoring transaction fee                                                       |
| useGlobalFeepayer | Whether KAS will pay data anchoring transaction fee (the transaction fee will be charged to the user later)            |

* Use `useGlobalFeepayer` to send the data anchoring transaction even if the KLAY balance is insufficient.
* An error will occur if all thee parameters are not set.
* The data anchoring transaction fee will be delegated according to the following priorities if one or more parameters are entered.

{% hint style="warning" %}
Use `useGlobalFeepayer`to guarantee the execution of anchoring transaction.
{% endhint %}

{% hint style="info" %}
To use `feepayer`, first create [fee-payer pool and fee-payer account](/kas-docs-dev/gitbook-wallet-account-api-en-add-java-example/getting-started/account.md#getting-started-account-createfp).\
The fee-payer account address and the KRN value of the fee-payer pool are required to use the `feepayer`.
{% endhint %}

The fee payment priority will be as follows if several parameters are used together to send anchoring transactions.

| Priority | Parameter         | the transaction fee payer                               |
| -------- | ----------------- | ------------------------------------------------------- |
| 1        | feepayer          | User's separate fee-payer account                       |
| 2        | useOperator       | Operator                                                |
| 3        | useGlobalFeepayer | KAS (transaction fee will be charged to the user later) |

The account with higher priority will pay the anchoring transaction fee first if all three parameters are used. If the operator struggles to pay the transaction fee because of insufficient `feepayer` account balance, the operator that sends an anchoring transaction will directly pay the fee as it has the next priority.

![Example of using feepayer and GlobalFeepayer](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2F5cd63d5b6aaeab270f98ec0d4f9dbb1241cc643c.png?generation=1601881549711655\&alt=media)

Expected behaviors according to parameter values are as follow:

| useGlobalFeepayer | feepayer | useOperator | Priority                        |
| ----------------- | -------- | ----------- | ------------------------------- |
| false             | X        | false       | Error                           |
| true              | X        | false       | KAS                             |
| false             | X        | true        | Operator                        |
| true              | X        | true        | Operator > KAS                  |
| false             | O        | false       | User fee-payer                  |
| false             | O        | true        | User fee-payer > Operator       |
| true              | O        | true        | User fee-payer > Operator > KAS |
| true              | O        | false       | User fee-payer > KAS            |

#### Create Operator

Once the parameters are set, create an operator.

![Information of Created Operator](https://4064829916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIr4aIKYb50HSQjs0vM%2Fsync%2F4c0f27cad66250e61b3614ed383ae39771cdf725.png?generation=1601881551890063\&alt=media)

You can check the created operator in the operator list.

For inquires about this document or KAS, please visit [Developer Forum](https://forum.klaytn.com/c/kas/kasen/27).
