Before Getting Started

  • The x-chain-id value for calling the API is 8217 (Mainnet) or 1001 (Kairos).
  • Essential parameters for calling APIs are described in individual examples.

Values that a user needs to enter for calling APIs will be represented with one pair of braces ({}). A user must enter the following values.

Item Description Note
chain-id 8217 or 1001 Kaia Mainnet or Kairos
access-key-id Auth ID accessKeyId obtained from KAS Console > [Security] > [Credential]
secret-access-key Auth Password secretAccessKey obtained from KAS Console > [Security] > [Credential]
krn (optional) ID of Account Pool Unnecessary when using Default Account Pool

A KAS API Authentication Key (API Auth Key) provides access to all KAS services and all the rights to a Kaia account which was created by calling Wallet API via this API Auth Key. The rights here include accessing and transferring all the assets (KAIA, etc.) of or sending a transaction from a Kaia account. If you shared your API Auth Key with any unauthorized personnel, your Kaia account could be compromised and might cause unwanted transaction execution.

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/Kaia account.

info

For details about KAS SDK (caver-js/caver-java extensions) installation and execution, please visit KAS SDK. For more details on creating an Account Pool, account, and selecting an account, refer to Getting Started.

Create a Account Pool

KAS provides Account Pool for managing several Kaia 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. You can create multiple Account Pools in KAS Console, and if you provided the KRN of each Account Pool as the x-krn in the API Request header that creates a Kaia account, you can create a Kaia account inside that specific Account Pool.

  • Kaia account

    A Kaia account is a host that owns and trades virtual assets, such as KAIA, token (FT, and NFT), and deploys and executes smart contracts on Kaia blockchain platform. For details about Kaia account, please visit here.

  • 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 Kaia 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 > Accounts 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 Kaia 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 Kaia account, KAS automatically create the default Account Pool and push this newly created Kaia account into this default Account Pool for you.

1. Generate Account Pools

Click the "Create" button under the KAS Console > Service > Wallet > Accounts menu. Then, click the button to display the screen for creating Kaia account Pools.

Service - Wallet - Accounts

2. Create an Account Pool

Create a Kaia account Pool, and it must have a different name from other Account Pools on the current KAS account.

Create Account Pool

3. Check the Account Pool

Once the Account Pool is created, check the Account Pool in the Account Pool list.

Created Account Pool

Create a Kaia Account

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 Kaia account stored in this Account Pool.

API Request

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

cURLJavaScriptJava
Copy
Copied
//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:8217:wallet:6698d79e-78ee-439a-815d-f293ec6ae736:account-pool:ap1"
Copy
Copied
const result = await caver.kas.wallet.createAccount();
Copy
Copied
Account account = caver.kas.wallet.createAccount();
System.out.println(account);

API Response

Here is the response of the Kaia account creation API.

cURLJavaScriptJava
Copy
Copied
//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:8217:wallet:6698d79e-78ee-439a-815d-f293ec6ae736:account-pool:ap1:0x4cbbcb974e32a7960e1b356edf60087613101919ed83199f12e872cba068a50f",
  "krn": "krn:8217:wallet:6698d79e-78ee-439a-815d-f293ec6ae736:account-pool:ap1",
  "publicKey": "0x04cdccfb99b2905561e3dd886687b429a004718f11b04914f17ce68fd3a0db46c598a45da85caa61fe84cb78a0f2eaa9983ec7b8805a93ef9428eb1350a8558237",
  "updatedAt": 1599187293
}
Copy
Copied
Account {
  address: '0x09634F250DeAaA20d0F93da624662eB5339E6212',
  chainId: 1001,
  createdAt: 1601970606,
  keyId: 'krn:1001:wallet:8e76d003-d6dd-4278-8d05-5172d8f010ca:account-pool:default:0xc8bca3c1f9e09d4f38b6a629f27fff9cab3ead3ddf3791c2df01d9f0d8b743f2',
  krn: 'krn:1001:wallet:8e76d003-d6dd-4278-8d05-5172d8f010ca:account-pool:default',
  publicKey: '0x04df8709251407a1663432ae0e0f21291b9d6ec01ad656773a56b951ebcc56c65323f4dfe7141ce71a6350f7186f6150db8833f30be357cc8bb4d416a9f5402548',
  updatedAt: 1601970606
}
Copy
Copied
class Account {
    address: 0x0BA67C887F922AF3d0D781dD940c6d0C80D395DE
    chainId: 1001
    createdAt: 1602550121
    keyId: krn:1001:wallet:d5c346f5-bb80-4f45-9093-57e25205cdc8:account-pool:pool:0xbedefad10db4df3488aaf1669b9164549c1aebe7c326f4b19ba6c6ce0f330fa5
    krn: krn:1001:wallet:d5c346f5-bb80-4f45-9093-57e25205cdc8:account-pool:pool
    publicKey: 0x041d56cbe46915854600c9d3c4ef614906f27473abe948cf587d990dcbce030d5989f4458bc470e44b2916d75194729102bb60e1e6a27c01030de84208a13232c2
    updatedAt: 1602550121
    multiSigKeys: null
    threshold: null
}

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developers Forum.

Get Information of a Kaia account

Kaia account search API is used for searching for the information of a created Kaia account.

API Request

Enter the account EOA, and then call the Kaia account search API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

cURLJavaScriptJava
Copy
Copied
curl --location --request GET "https://wallet-api.klaytnapi.com/v2/account/0xa809284C83b901eD106Aba4Ccda14628Af128e14" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}"
Copy
Copied
const result = await caver.kas.wallet.getAccount(accountToTest.address);
Copy
Copied
String address = "0xBD1b03C426Bfa132C838C05846D61941C5b6e820";
Account account = caver.kas.wallet.getAccount(address);
System.out.println(account);

API Response

Here is a response of the Kaia account search API.

cURLJavaScriptJava
Copy
Copied
{
  "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
}
Copy
Copied
Account {
  address: '0x74a0a04c16025da4d24154440918035497795c14',
  chainId: 1001,
  createdAt: 1601970655,
  keyId: 'krn:1001:wallet:8e76d003-d6dd-4278-8d05-5172d8f010ca:account-pool:default:0x5870e94faea33f3f447cc588a1d09a98c8926f258efccb01678e6c98112c1fb7',
  krn: 'krn:1001:wallet:8e76d003-d6dd-4278-8d05-5172d8f010ca:account-pool:default',
  publicKey: '0x04686e10c48f86bf6a2127b429b5cd2fe308ac50b57db123ba3760fd845872c0d01c5f55792d5dff79a3fc3bc972af8b8a67a8bcbf906c1bd1e1e53b8c1e537f9e',
  updatedAt: 1601970655
}
Copy
Copied
class Account {
    address: 0xBD1b03C426Bfa132C838C05846D61941C5b6e820
    chainId: 1001
    createdAt: 1602550228
    keyId: krn:1001:wallet:d5c346f5-bb80-4f45-9093-57e25205cdc8:account-pool:pool:0x8a13fa72996d1ea1c9619326846854ae906d65ed11e4f89642fff5329c231c36
    krn: krn:1001:wallet:d5c346f5-bb80-4f45-9093-57e25205cdc8:account-pool:pool
    publicKey: 0x046fd7fb4be4ac31b2f7822a4a1a05a2a510dc810af44497491e4a1b657b9724b4980238a0a9b56e3fa8570ac89ce352ba1de348a18751c83bd55c29a243d8f5c8
    updatedAt: 1602550228
    multiSigKeys: null
    threshold: null
}

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developers Forum.

Get the list of Kaia accounts

Kaia account list search API is used for looking for created Kaia account lists.

API Request

Call the Kaia account list search API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

Query Parameter

You can receive API response values with Cursor-based Pagination. The search range can also be set by second.

cURLJavaScriptJava
Copy
Copied
curl --location --request GET "https://wallet-api.klaytnapi.com/v2/account?&size=100&cursor=&from-timestamp=1592360291&to-timestamp=15991809920" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}"
Copy
Copied
const query = {
  size: 1,
  fromTimestamp: 1501970769,
  toTimestamp: 1601970769,
  cursor:
    "eyJBZGRyZXNzIjoia3JuOjEwMDE6d2FsbGV0OjhlNzZkMDAzLWQ2ZGQtNDI3OC04ZDA1LTUxNzJkOGYwMTBjYTphY2NvdW50LXBvb2w6ZGVmYXVsdDoweDUzM0ZjQzMyMWE4ODgxQzllNEEzNUIzMUJhZWI4MEI1MWE3RDI2OEQiLCJUeXBlIjoiQUNDIiwiY3JlYXRlZF9hdCI6MTYwMTk3MDc2OSwicnBuIjoia3JuOjEwMDE6d2FsbGV0OjhlNzZkMDAzLWQ2ZGQtNDI3OC04ZDA1LTUxNzJkOGYwMTBjYTphY2NvdW50LXBvb2w6ZGVmYXVsdCJ9",
};
const result = await caver.kas.wallet.getAccountList(query);
Copy
Copied
WalletQueryOptions options = new WalletQueryOptions();
options.setSize((long)1);
options.setFromTimestamp((long)1601020759);
options.setToTimestamp((long)1602495442l);

Accounts accounts = caver.kas.wallet.getAccountList(options);
System.out.println(accounts);

API Response

Here is the response of the Kaia account list search API.

cURLJavaScriptJava
Copy
Copied
{
  "cursor": "",
  "items": [
    {
      "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
    },
    {
      "address": "0x78B123CCCCd50f41E3192a60e6ED92B15E21b1B5",
      "chainId": 1001,
      "createdAt": 1599187194,
      "keyId": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default:0x6c4419647e7724853f9e50b0c54b5985d0870470ac37b3ef865e62c3ccfa4ea4",
      "krn": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default",
      "publicKey": "0x0463cc38f08dd15dfd416966e9d0da93942e26d2a9a9bcac08d614f487f94a7e46e4418d1acda9e21706f19c917486de40c974eb20c12a2eca2eea91895499d379",
      "updatedAt": 1599187194
    },
   ...
   ,
    {
      "address": "0x7ec5169EA28B2e3fFEF143a3513D7eC1CeFF2cB4",
      "chainId": 1001,
      "createdAt": 1599187161,
      "keyId": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default:0xd3ee56e2616c8d412918e7f0e9222c805aacf5bad6d84b70b83c2229d61f21c9",
      "krn": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default",
      "publicKey": "0x043ccf257d2ad3f8c3b2128969302efc6bf59d8cd8e578bcfdac8a4ac9cea6d4747350c98edaec5d23fafa9b3288a3b45816d2e9b3bb28443cc2486ad6bca652f1",
      "updatedAt": 1599187161
    }
  ]
}
Copy
Copied
Accounts {
  cursor: 'eyJBZGRyZXNzIjoia3JuOjEwMDE6d2FsbGV0OjhlNzZkMDAzLWQ2ZGQtNDI3OC04ZDA1LTUxNzJkOGYwMTBjYTphY2NvdW50LXBvb2w6ZGVmYXVsdDoweERGZTdlMjBGMjNhNDBDM0M4OTExMzk2YUYzREJhMjU3NTEzQzM5NTkiLCJUeXBlIjoiQUNDIiwiY3JlYXRlZF9hdCI6MTYwMTk3MDczOSwicnBuIjoia3JuOjEwMDE6d2FsbGV0OjhlNzZkMDAzLWQ2ZGQtNDI3OC04ZDA1LTUxNzJkOGYwMTBjYTphY2NvdW50LXBvb2w6ZGVmYXVsdCJ9',
  items: [
    Account {
      address: '0xDFe7e20F23a40C3C8911396aF3DBa257513C3959',
      chainId: 1001,
      createdAt: 1601970739,
      keyId: 'krn:1001:wallet:8e76d003-d6dd-4278-8d05-5172d8f010ca:account-pool:default:0x2a6b68676a8ab5312d606aef6198b86399091c791264a77dfb351fc1860ab158',
      krn: 'krn:1001:wallet:8e76d003-d6dd-4278-8d05-5172d8f010ca:account-pool:default',
      publicKey: '0x04e58e1011de62f6981af17faa4b11aa8c2bcafd6a9765db2df57decb6cc4500ee0d82ecba932ffc5bdee883d970944f4098627a631a0b1d84b270dbf4ea811a9d',
      updatedAt: 1601970739
    }
  ]
}
Copy
Copied
class Accounts {
    cursor: eyJBZGRyZXNzIjoia3JuOjEwMDE6d2FsbGV0OmQ1YzM0NmY1LWJiODAtNGY0NS05MDkzLTU3ZTI1MjA1Y2RjODphY2NvdW50LXBvb2w6cG9vbDoweEEzNjQwRTdkMDM3ODRhODE2N0ZjNTU0N0RFNUYxODRmNkM4ZTRFRWIiLCJUeXBlIjoiQUNDIiwiY3JlYXRlZF9hdCI6MTYwMjQ5NTQ0MiwicnBuIjoia3JuOjEwMDE6d2FsbGV0OmQ1YzM0NmY1LWJiODAtNGY0NS05MDkzLTU3ZTI1MjA1Y2RjODphY2NvdW50LXBvb2w6cG9vbCJ9
    items: [class Account {
        address: 0xA3640E7d03784a8167Fc5547DE5F184f6C8e4EEb
        chainId: 1001
        createdAt: 1602495442
        keyId: krn:1001:wallet:d5c346f5-bb80-4f45-9093-57e25205cdc8:account-pool:pool:0xa52d4457198474d1aa314c6fab1a77a92ca4b8969a3c605e5083bd7bcd37b890
        krn: krn:1001:wallet:d5c346f5-bb80-4f45-9093-57e25205cdc8:account-pool:pool
        publicKey: 0x048c6ed6327200eac60eea1dd07df87d927f473f67298c91b0195d519ec3ed07218d905dbc46d2af5a456ba661d8474cada5fd99c8063f42dfa9605094bf6ce40c
        updatedAt: 1602495442
        multiSigKeys: null
        threshold: null
    }]
}

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developers Forum.

Delete Kaia account

Kaia account deletion API is used for deleting Kaia accounts.

warning

Once a Kaia account was deleted, you cannot sign on any transaction with this account.

API Request

Enter the EOA to delete and call the Kaia account deletion API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

cURLJavaScriptJava
Copy
Copied
curl --location --request DELETE "https://wallet-api.klaytnapi.com/v2/account/0xa809284C83b901eD106Aba4Ccda14628Af128e14" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}"
Copy
Copied
const result = await caver.kas.wallet.deleteAccount(created.address);
Copy
Copied
String account = "0x9D2978c98A165EA2F426035C1c13D1871Ca83646";
AccountStatus accountStatus = caver.kas.wallet.deleteAccount(account);

System.out.println(accountStatus);

API Response

Here is a response of the Kaia account deletion API.

cURLJavaScriptJava
Copy
Copied
{
  "status": "deleted"
}
Copy
Copied
AccountStatus { status: 'deleted' }
Copy
Copied
class AccountStatus {
    status: deleted
}

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developers Forum.

Deactivate Kaia account

Kaia account deactivation API is used for deactivating created Kaia accounts.

API Request

Enter the EOA to deactivate and call the Kaia account deactivation API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

cURLJavaScriptJava
Copy
Copied
curl --location --request PUT "https://wallet-api.klaytnapi.com/v2/account/0xa809284C83b901eD106Aba4Ccda14628Af128e14/disable" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}"
Copy
Copied
const result = await caver.kas.wallet.disableAccount(accountToTest.address);
Copy
Copied
String address = "0x10Fb446303d019E89c2033C833ceC2e5ae875b5F";

AccountSummary status = caver.kas.wallet.disableAccount(address);
System.out.println(status);

API Response

Here is a response of the Kaia account deactivation API.

cURLJavaScriptJava
Copy
Copied
{
  "address": "0xa809284C83b901eD106Aba4Ccda14628Af128e14",
  "krn": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default",
  "updatedAt": 1599187344
}
Copy
Copied
AccountSummary {
  address: '0xE80bFBE82230ff91113728f2392a9bf2b607393a',
  krn: 'krn:1001:wallet:8e76d003-d6dd-4278-8d05-5172d8f010ca:account-pool:default',
  updatedAt: 1601971006
}
Copy
Copied
class AccountSummary {
    address: 0x10Fb446303d019E89c2033C833ceC2e5ae875b5F
    krn: krn:1001:wallet:d5c346f5-bb80-4f45-9093-57e25205cdc8:account-pool:pool
    updatedAt: 1602550794
}

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developers Forum.

Activate Kaia account

Kaia account activation API is used for activating created Kaia accounts.

API Request

Enter the EOA to activate and call the Kaia account activation API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

cURLJavaScriptJava
Copy
Copied
curl --location --request GET "https://wallet-api.klaytnapi.com/v2/account/0xa809284C83b901eD106Aba4Ccda14628Af128e14/enable" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}"
Copy
Copied
const result = await caver.kas.wallet.enableAccount(accountToTest.address);
Copy
Copied
String address = "0xDEe95846929A2703D57F2d2994ee64316f771418";
AccountSummary enableSummary = caver.kas.wallet.enableAccount(address);

System.out.println(enableSummary);

API Response

Here is a response of the Kaia account activation API.

cURLJavaScriptJava
Copy
Copied
{
  "address": "0xa809284C83b901eD106Aba4Ccda14628Af128e14",
  "krn": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default",
  "updatedAt": 1599187359
}
Copy
Copied
AccountSummary {
  address: '0xE80bFBE82230ff91113728f2392a9bf2b607393a',
  krn: 'krn:1001:wallet:8e76d003-d6dd-4278-8d05-5172d8f010ca:account-pool:default',
  updatedAt: 1601971006
}
Copy
Copied
class AccountSummary {
    address: 0xDEe95846929A2703D57F2d2994ee64316f771418
    krn: krn:1001:wallet:d5c346f5-bb80-4f45-9093-57e25205cdc8:account-pool:pool
    updatedAt: 1602551180
}

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developers Forum.

Sign A Transaction with Kaia account

Sign a transaction with a specific transaction ID using the Kaia account. This API is used only when a transaction need to be signed with multiple signatures. If this is not the case of multiple signing, normally Wallet API automatically signs a transaction instead of you when you are sending a transaction through Wallet API.

info

Multiple signing is the case that a Kaia account who sends a transaction has AccountKeyWeightedMultiSig. For details about multiple signing, please visit here.

info

For details about the types of AccountKey of a Kaia account, please visit here.

API Request

Enter the Kaia EOA and the transaction ID value to sign and receive the signature, respectively. Then, call this API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

info

Transaction ID can be obtained from the API response of Get List of Pending Transactions.

cURLJavaScriptJava
Copy
Copied
curl --location --request POST "https://wallet-api.klaytnapi.com/v2/account/0xa809284C83b901eD106Aba4Ccda14628Af128e14/tx/{transaction-id}/sign" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}"
Copy
Copied
const address = "0xDbe780a8db6Dd219Fad25CDe29cB27392714f3ba";
const transactionId =
  "0x846534f00729fb838ade7478770d32d54f2b9ad4994f0c2ba8c5d569b241ae77";
const result = await caver.kas.wallet.signTransaction(address, transactionId);
Copy
Copied
String address = "0xDbe780a8db6Dd219Fad25CDe29cB27392714f3ba";
String transactionId = "0x846534f00729fb838ade7478770d32d54f2b9ad4994f0c2ba8c5d569b241ae77";
Signature signature = caver.kas.wallet.signTransaction(address, transactionId);

System.out.println(signature);

API Response

Here is a response of the transaction signature API. The ECDSA signature information (R, S) and public key restoration information (V) are then returned.

cURLJavaScriptJava
Copy
Copied
{
  "R": "0x670a63ca525b80f67cd412a88ffb5cabb84616fb4cb43ff827552586fc722403",
  "S": "0x2f20ad3f4b3c2483a4ae4213a871e404f7214ffd84845fad022c3316eb0af09b",
  "V": "0x7f6"
}
Copy
Copied
Signature {
  R: '0x9f1c0bafa5763120c2cbcdf80c73874cf37d63a2ed71799de3ff8d61ccc29b4d',
  S: '0x5d2266f82e1089141de759c63e49d275cabcd7cf5f723615750abc0efc8dfc69',
  V: '0x7f6'
}
Copy
Copied
class Signature {
    R: 0xdf18c28d936cc411732ec3d1c00a0ec1ae5c4f9910f3aa529c566a46a058e0e1
    S: 0x3825119d0c74b9dcb1dd8fb5636e09b1c7544110173ac47394a38df3c0f41901
    V: 0x7f6
}

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developers Forum.

Get Kaia account Information by Public Key

This API searches for the details of a Kaia account using a specific public key.

API Request

Enter the public key, and call the API to search for information regarding a Kaia account. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

cURLJavaScriptJava
Copy
Copied
curl --location --request GET "https://wallet-api.klaytnapi.com/v2/pubkey/0x049e00f9fbc12f01./account" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}"
Copy
Copied
const publicKey =
  "0x04334fbfedaa65df28797fdbd54778179ecc0929ddf40189e1470029e5efca4a0fadd510680228d261234e11f425ce85adb2a3ad014b2bb07470e66425ed483fd0";
const result = await caver.kas.wallet.getAccountListByPublicKey(publicKey);
Copy
Copied
String publicKey = "0x04f715a9d9e0f7a4b152d4ef8a67f4708fc1f83fe2e1984cf0f72987dbacbad324fb619fbdf30497441eddf80676403f0009f07b4195915df7220c79183e9d1f27";
AccountsByPubkey accounts = caver.kas.wallet.getAccountListByPublicKey(publicKey);

System.out.println(accounts);

API Response

Here is a response of the Kaia account search API using the public key.

cURLJavaScriptJava
Copy
Copied
{
  "items": [
    {
      "address": "0x0b7caaf70e7A0a5399041c64711E535CE8B3cf7d",
      "chainId": 1001
    },
    {
      "address": "0xc6C9356887b7F7887918Bf577417E5D8De253295",
      "chainId": 1001
    }
  ]
}
Copy
Copied
AccountsByPubkey {
  items: [
    AccountByPubkey {
      address: '0x8e53770c83c1Ec6C52226Bc27B1743731486a61b',
      chainId: 1001
    }
  ]
}
Copy
Copied
class AccountsByPubkey {
    items: [class AccountByPubkey {
        address: 0x0be73FcBE9F4D66b949eCC0a61325170460e4f88
        chainId: 1001
    }]
}

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developers Forum.

Update AccountKey: To AccountKeyWeightedMultiSig

A Kaia account which is able to sign with multiple signatures is an account that has AccountKeyWeightedMultiSig, a type of AccountKey. This type of Kaia account must be used when sending a transaction that multiple Kaia accounts need to sign with each one's AccountKey. We can call this special kind of transaction as multisig transactions. Similar to Kaia, KAS also supports multisig transactions. For sending multisig transactions using KAS, AccountKey must be the multisig key (AccountKeyWeightedMultiSig).

A Kaia account that owns AccountKeyWeightedMultiSig has several keys (private-public key pairs) for multisig transactions, and different Kaia accounts owns these keys, each. And, the weight can be set for individual keys.

For example, if Kaia account A has a AccountKeyWeightedMultiSig consisting of 2 AccountKeys (AccountKey of accounts B and C each), and the weights of these keys can be weight1 and weight2, respectively. When the account B signs this transaction, the sum of signed weight is weight1, and if account C also signs it, the sum will be weight1 + weight2. A transaction can be sent only if the sum of signed weights is the same with or higher than the threshold. The threshold value is given as a input parameter when you create AccountKeyWeightedMultiSig for your Kaia account.

info

For details about AccountKeyWeightedMultiSig, please visit here.

Creating Kaia account must be completed before updating your AccountKey to AccountKeyWeightedMultiSig. All Kaia accounts whose key contributes to form a AccountKeyWeightedMultiSig must be located in the same Account Pool in KAS. Here is an example of updating a Kaia account with the EOA "0x07DAe1aAb1e1b42A7184E12Ad50CEAc07A890640" to a multisig account (=an account whose AccountKey is AccountKeyWeightedMultiSig) consisting of 2 AccountKeys.

If Kaia account A is a multisig account with two keys (AccountKeys), then account A can have two keys (keys of account B and C). For account A to have AccountKeyWeightedMultiSig with the keys Account B and C, the Kaia accounts B and C must have been created in KAS. For more details on creating a Kaia account in KAS, refer to Create Kaia account.

The below is the example of created Kaia accounts.

Copy
Copied
//Account A
{
  "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
}
//Account B
{
  "address": "0x78B123CCCCd50f41E3192a60e6ED92B15E21b1B5",
  "chainId": 1001,
  "createdAt": 1599187194,
  "keyId": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default:0x6c4419647e7724853f9e50b0c54b5985d0870470ac37b3ef865e62c3ccfa4ea4",
  "krn": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default",
  "publicKey": "0x0463cc38f08dd15dfd416966e9d0da93942e26d2a9a9bcac08d614f487f94a7e46e4418d1acda9e21706f19c917486de40c974eb20c12a2eca2eea91895499d379",
  "updatedAt": 1599187194
}
//Account C
{
  "address": "0x7ec5169EA28B2e3fFEF143a3513D7eC1CeFF2cB4",
  "chainId": 1001,
  "createdAt": 1599187161,
  "keyId": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default:0xd3ee56e2616c8d412918e7f0e9222c805aacf5bad6d84b70b83c2229d61f21c9",
  "krn": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default",
  "publicKey": "0x043ccf257d2ad3f8c3b2128969302efc6bf59d8cd8e578bcfdac8a4ac9cea6d4747350c98edaec5d23fafa9b3288a3b45816d2e9b3bb28443cc2486ad6bca652f1",
  "updatedAt": 1599187161
}

This API updates your account ("A" in this example) to a multisig account that can send transactions with signatures of other Kaia accounts ("B", "C" in this example). Here is an example of updating a Kaia account ("A") with the EOA "0xa809284C83b901eD106Aba4Ccda14628Af128e14" to a multisig account with two keys (of account B and C), key weights (3 and 1, respectively), and a threshold of 4.

info

To update your Kaia account, call this API and send account update transaction to Kaia. The Kaia account who sends this transaction must have sufficient balance to pay for the transaction fee.

API Request

Call the multisig account update API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

cURLJavaScriptJava
Copy
Copied
curl --location --request PUT "https://wallet-api.klaytnapi.com/v2/account/0xa809284C83b901eD106Aba4Ccda14628Af128e14/multisig" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
--header "Content-Type: application/json" \
--data-raw "{
    "threshold": 4,
    "weightedKeys": [
        {
            "weight": 3,
            "publicKey": "0x0463cc38f08dd15dfd416966e9d0da93942e26d2a9a9bcac08d614f487f94a7e46e4418d1acda9e21706f19c917486de40c974eb20c12a2eca2eea91895499d379"
        },
        {
            "weight": 1,
            "publicKey": "0x043ccf257d2ad3f8c3b2128969302efc6bf59d8cd8e578bcfdac8a4ac9cea6d4747350c98edaec5d23fafa9b3288a3b45816d2e9b3bb28443cc2486ad6bca652f1"
        }
    ]
}"
Copy
Copied
const address = "0x385500f711c20f22Ebe9599C7cb7Ed2e8495AA87";
const weightedMultisig = {
  threshold: 3,
  weightedKeys: [
    {
      weight: 1,
      publicKey:
        "0x047080d0a3368c2e6e2e03dbe40e82a07109bcbff199fc1650b4ed1d0a2bd7a39eef8c1b6d59423e2de48f391ed996eee6fa876be13c54fafde52301f290453c9a",
    },
    {
      weight: 1,
      publicKey:
        "0x04023337c168044de198c556a842344c3c3b173a5b8628ad2f9b0bf5b8481847844cda8b08acfec66fd483fcf2a3b007adf1f34d72aae59df664b031e012bae72a",
    },
    {
      weight: 1,
      publicKey:
        "0x0429f095fabc59bd3dadf43103acc5a1c090d0fe238b7d8ebd89684a768ca21fa82ad4dfb146825783c8b2e0f51c9d0f9ddea57bce65cf7e967f8454ba3195dc86",
    },
  ],
};
const result = await caver.kas.wallet.updateToMultiSigAccount(
  address,
  weightedMultisig
);
Copy
Copied
String address = "0x95AdA22b2C49C31b070b22347485B6739D00e32a";
String[] publicKeyArr = new String[] {
        "0x044b36e9c4e8c6bea364c3c4d214625a70e5e697ac551d99a6eb39197b3c26640dbaaa11b7dc36c2ca3b447bb78a27bb00f4e8fef5ed3401db1358270c52dee9f4",
        "0x047fa3b3a09e9846edecfa1548ecb131c9705255685bfb9b0620de6c7e97d4f17d828317c6ff9dfcebc9bb5086cddf3dbc1ca552c6fc0e019f266b24c6b46ae782",
        "0x0462f067faefd6d087f0e087abc23802af0721302777ed8e77c4544eabf031c794ebf0b83dfad9932b972a0e1b8e3abd31560e97a8610303026806db8e8081d0fe"
};

List<MultisigKey> multiSigKeys = Arrays.stream(publicKeyArr).map(key -> {
    MultisigKey multisigKey = new MultisigKey();
    multisigKey.setWeight((long)2);
    multisigKey.setPublicKey(key);

    return multisigKey;
}).collect(Collectors.toList());

MultisigAccountUpdateRequest request = new MultisigAccountUpdateRequest();
request.setThreshold((long)3);
request.setWeightedKeys(multiSigKeys);

MultisigAccount account = caver.kas.wallet.updateToMultiSigAccount(address, request);
System.out.println(account);

API Response

Here is a response of the multisig account update API.

cURLJavaScriptJava
Copy
Copied
{
  "code": 0,
  "result": {
    "address": "0xa809284C83b901eD106Aba4Ccda14628Af128e14",
    "krn": "krn:1001:wallet:test:account-pool:rp1",
    "multiSigKeys": [
      {
        "publicKey": "0x0463cc38f08dd15dfd416966e9d0da93942e26d2a9a9bcac08d614f487f94a7e46e4418d1acda9e21706f19c917486de40c974eb20c12a2eca2eea91895499d379",
        "weight": 3
      },
      {
        "publicKey": "0x043ccf257d2ad3f8c3b2128969302efc6bf59d8cd8e578bcfdac8a4ac9cea6d4747350c98edaec5d23fafa9b3288a3b45816d2e9b3bb28443cc2486ad6bca652f1",
        "weight": 1
      }
    ],
    "threshold": 4,
    "transactionHash": "0x2b0f6ecd671e4a7075f22c7f46ea43ab8016747e6aae05d8dac4f487a3e640a0",
    "updatedAt": 1597297768
  }
}
Copy
Copied
MultisigAccount {
  address: '0x385500f711c20f22Ebe9599C7cb7Ed2e8495AA87',
  krn: 'krn:1001:wallet:8e76d003-d6dd-4278-8d05-5172d8f010ca:account-pool:default',
  threshold: 3,
  transactionHash: '0x69c65222d9ea58b2674b11f04d5fa6b40176fc93639909eb303a237de868fa8b',
  updatedAt: 1601971504,
  multiSigKeys: [
    MultisigKey {
      publicKey: '0x047080d0a3368c2e6e2e03dbe40e82a07109bcbff199fc1650b4ed1d0a2bd7a39eef8c1b6d59423e2de48f391ed996eee6fa876be13c54fafde52301f290453c9a',
      weight: 1
    },
    MultisigKey {
      publicKey: '0x04023337c168044de198c556a842344c3c3b173a5b8628ad2f9b0bf5b8481847844cda8b08acfec66fd483fcf2a3b007adf1f34d72aae59df664b031e012bae72a',
      weight: 1
    },
    MultisigKey {
      publicKey: '0x0429f095fabc59bd3dadf43103acc5a1c090d0fe238b7d8ebd89684a768ca21fa82ad4dfb146825783c8b2e0f51c9d0f9ddea57bce65cf7e967f8454ba3195dc86',
      weight: 1
    }
  ]
}
Copy
Copied
class MultisigAccount {
    address: 0x95AdA22b2C49C31b070b22347485B6739D00e32a
    krn: krn:1001:wallet:d5c346f5-bb80-4f45-9093-57e25205cdc8:account-pool:pool
    multiSigKeys: [class MultisigKey {
        publicKey: 0x044b36e9c4e8c6bea364c3c4d214625a70e5e697ac551d99a6eb39197b3c26640dbaaa11b7dc36c2ca3b447bb78a27bb00f4e8fef5ed3401db1358270c52dee9f4
        weight: 2
    }, class MultisigKey {
        publicKey: 0x047fa3b3a09e9846edecfa1548ecb131c9705255685bfb9b0620de6c7e97d4f17d828317c6ff9dfcebc9bb5086cddf3dbc1ca552c6fc0e019f266b24c6b46ae782
        weight: 2
    }, class MultisigKey {
        publicKey: 0x0462f067faefd6d087f0e087abc23802af0721302777ed8e77c4544eabf031c794ebf0b83dfad9932b972a0e1b8e3abd31560e97a8610303026806db8e8081d0fe
        weight: 2
    }]
    threshold: 3
    transactionHash: 0xd727d047c413b3a23c0c003169e816aaee82c404eadac1edae5dc16d86317f6d
    updatedAt: 1602552587
}

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developers Forum.

Creating Account Update Transaction

You have to create an account update transaction with the key from your old account.

danger

Make sure to use Fee Delegation Account Update Transaction from Public Key Type. Creating account update transations with key types other than the public key type may prevent you from using your account.

If you wish to use multisig account, first complete the procedures for migration and then make the changes using Wallet API's Multisig Account Update API. Refer to how to migrate for migration.

API Request

JavaScriptJava
Copy
Copied
// In order to migrate Kaia account to KAS Wallet API, you have to create a transaction and sign it before sending it to KAS.
// In order to sign the transaction, create a Keyring instance with Kaia account and add it to KeyringContainer.
// If Kaia's key is either `AccountKeyWeigthedMultiSig`or `AccountKeyRoleBased`,
// pass the second parameter of `keyringContainer.keyring.create` as array or double-array.
// For more details, please refer to https://docs.klaytn.com/dapp/sdk/caver-js/api-references/caver.wallet/keyring#caver-wallet-keyring-create.
const keyringContainer = new caver.keyringContainer();
const keyring = keyringContainer.keyring.create(
  "0xc756f6809bc34c2458fcb82fb16d5add3dbad9e3",
  "0x{private key}"
);
keyringContainer.add(keyring);

// Create key for KAS Wallet API
// `caver.kas.wallet.createKeys` returns the following values.
// {
//     items: [
//         { blob: '0x06000...', keyId: 'krn:1001:...', krn: 'krn:1001:...', publicKey: '0x0400e...', },
//     ],
// }
const createdKeys = await caver.kas.wallet.createKeys(1);
const key = createdKeys.items[0];

// FeeDelegatedAccountUpdate Create transation.
// The value assigned to `account` field can be created using `caver.account.createWithAccountKeyPublic`.
// Address of the account to be migrated, public key (in the form of public key string) and KAS Wallet API must be passed as parameters.
const updateTx = new caver.transaction.feeDelegatedAccountUpdate({
  from: keyring.address,
  account: caver.account.createWithAccountKeyPublic(
    keyring.address,
    key.publicKey
  ),
  gas: 1000000,
});

// Sign transaction.
await keyringContainer.sign(keyring.address, updateTx);

const result = {
  keyId: key.keyId,
  address: keyring.address,
  rlp: updateTx.getRLPEncoding(),
};
Copy
Copied
// In order to migrate your Klaytn account to KAS Wallet API, you have to create and sign a transaction before sending it to KAS.
// In order to sign the transaction, create a Keyring instance with the Klaytn account and pass it as  a parameter when signing the transaction.
// If Klaytn's key is either `AccountKeyWeigthedMultiSig`or `AccountKeyRoleBased`,
// pass the second parameter of `KeyringFactory.create` as a String[] or a List<String[]>.
// For more details, please refer to https://javadoc.io/doc/com.klaytn.caver/core/latest/com/klaytn/caver/wallet/keyring/KeyringFactory.html.

AbstractKeyring keyring = KeyringFactory.create("0xc756f6809bc34c2458fcb82fb16d5add3dbad9e3", "0x{private key}");

// Create key for KAS Wallet API
// `caver.kas.wallet.createKeys` returns the following values.
// {
//     items: [
//         { blob: '0x06000...', keyId: 'krn:1001:...', krn: 'krn:1001:...', publicKey: '0x0400e...', },
//     ],
// }
KeyCreationResponse keyCreationResponse = caver.kas.wallet.createKeys(1);
List<Key> createdKeys = keyCreationResponse.getItems();
Key key = createdKeys.get(0);

// Create the FeeDelegatedAccountUpdate transaction.
// The value assigned to `account` field can be created using `caver.account.createWithAccountKeyPublic`.
// Address of the account to be migrated, public key (in the form of public key string) and KAS Wallet API must be passed as parameters.
FeeDelegatedAccountUpdate updateTx = caver.transaction.feeDelegatedAccountUpdate.create(
        TxPropertyBuilder.feeDelegatedAccountUpdate()
                .setFrom(keyring.getAddress())
                .setAccount(
                        caver.account.createWithAccountKeyPublic(
                                keyring.getAddress(),
                                key.getPublicKey()
                        )
                )
                .setGas(BigInteger.valueOf(1000000))
);

// Sign the transaction.
updateTx.sign(keyring);

System.out.println("keyId: " + key.getKeyId());
System.out.println("address: " + keyring.getAddress());
System.out.println("rlp: " + updateTx.getRLPEncoding());

For more details regarding this API, please refer to here. For any inquiries regarding this document or KAS in general, please visit KAS Developers Forum.