Update AccountKey

This page introduces how to send a transaction that updates your Klaytn accountKey with Wallet API.

Before Getting Started

  • The x-chain-id value for calling the API is 8217 (Cypress) or 1001 (Baobab).

  • 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

Cypress(Klaytn mainnet) or Baobab(Klaytn testnet

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 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 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.

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.

Update Klaytn account

Updating a Klaytn account into another account means changing the account key to another. For example, transforming a legacy account into a multisig account means changing the Klaytn account key from a legacy key (AccountKeyLegacy) to a multisig key (AccountKeyWeightedMultiSig).

For details about Klaytn account and AccountKey, please visit here.

Klaytn accountKey

All transactions require signatures to be sent to Klaytn and executed there. The Klaytn account key is mainly used for signing transactions, but KAS users can send transactions without signing under general conditions (sending KLAY, deploying smart contracts, etc.). Examples of special situations include one transaction requiring signatures from several accounts (multisig) or a Klaytn account outside KAS (external signature).

KAS also provides the Signing Transaction API.

Klaytn account keys for signing transactions include General Public Key, Multiple Signing Key, and Role-Based Key.

For details about keyType of Klaytn accountKey, please visit here.

Update AccountKey to AccountKeyWeightedMultiSig: Direct Payment of Transaction Fee

Send a transaction for changing a Klaytn account key into a multisig key. Instead of the multisig key, an account key can be changed into another type of key. For more details about types of Klaytn account keys, refer to the followings.

Updating your Klaytn account into a multisig account means transforming your AccountKey into an AccountKeyWeightedMultiSig.

Accounts that contributes to form an AccountKeyWeightedMultiSig must be located in the same Account Pool.

To send the account update transaction, a user must send a transaction to Klaytn Node and pay the transaction fee. In this example, the account must pay the transaction fee for sending the account update transaction. To call the API, he/she must create an Account Pool and account, and then select an account to use.

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.

API Request

Enter the account and new key information, and call the account update transaction transmission API. You can use the REST API or SDK (caver-js/caver-java) for calling the API. The following API call example updates the Klaytn account to a multisig account (to have a multisig key) with a threshold of 3 and 4 accoun keys for signing a transaction, with each key being assigned weight of 1.

curl --location --request PUT "https://wallet-api.klaytnapi.com/v2/tx/account" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
--header "Content-Type: application/json" \
--data-raw "{
  "from": "0x5bb85d4032354E88020595AFAFC081C24098202e",
  "accountKey": {
    "keyType": 4,
    "key": {
      "threshold": 3,
      "weightedKeys": [
        {
          "weight": 1,
          "publicKey": "0x041c5c34cafdefddfd5d0c8baa9e9f75ff6aa6dc597776e5bf06e231c57926a2cb9a86f9d30c4760e70f30f08cf234e7847365bc5a1696223cfef73cd188e422ec"
        },
        {
          "weight": 1,
          "publicKey": "0x045552e73f34964eb04cad0d3c3dbd7cfeebbfb420ca83b1e7c640a9c76b42a4ca2308ddbdee4044c9f52a248ce3eee51c155c9d0567f3ebb32b4db38962f30f66"
        },
        {
          "weight": 1,
          "publicKey": "0x04ab9910325fd645a556fee3c6bbd8651be4fbff6688634d826474f3ef4baff7b1e4e48936db4cdb0fb3474beea3ba870bb0e7f9b0eb7c9e7b4e613bca90dec2"
        },
        {
          "weight": 1,
          "publicKey": "0x04a1c4e3830f19d1fb2c78d00cd5b29f75cdcc706a8611cbf4192c2d20f4899cba2ecee4706d0c58bdcbc2a634f7794cd43ecf02c6f1fc383a8bf8b1509dfdc493"
        }
      ]
    }
  },
  "nonce": 0,
  "gasLimit": 1000000,
  "submit": true
}"
  • submit: If it is false, a transaction is not sent and the RLP of signed transaction and the transaction information are returned.

API Response

Here is the response of the account update transaction transmission API.

{
  "accountKey": "0x04f89303f890e301a1021c5c34cafdefddfd5d0c8baa9e9f75ff6aa6dc597776e5bf06e231c57926a2cbe301a1025552e73f34964eb04cad0d3c3dbd7cfeebbfb420ca83b1e7c640a9c76b42a4cae301a102ab9910325fd645a556fee3c6bbd8651be4fbff6688634d826474f3ef4baff7b1e301a103a1c4e3830f19d1fb2c78d00cd5b29f75cdcc706a8611cbf4192c2d20f4899cba",
  "from": "0x325dbaf78b393dc2115138c86a58f897ed413aff",
  "gasLimit": 1000000,
  "gasPrice": "0x5d21dba00",
  "nonce": 2,
  "rlp": "0x20f90101028505d21dba00830f424094325dbaf78b393dc2115138c86a58f897ed413affb89604f89303f890e301a1021c5c34cafdefddfd5d0c8baa9e9f75ff6aa6dc597776e5bf06e231c57926a2cbe301a1025552e73f34964eb04cad0d3c3dbd7cfeebbfb420ca83b1e7c640a9c76b42a4cae301a102ab9910325fd645a556fee3c6bbd8651be4fbff6688634d826474f3ef4baff7b1e301a103a1c4e3830f19d1fb2c78d00cd5b29f75cdcc706a8611cbf4192c2d20f4899cbaf847f8458207f5a0c669b62293629316d18e12cd90d5c4dc24000e13d31200c53e40ac8f01bf249ea062be831829631503e20cccd160fe1ec450950e6f982df16d83d3f6f948924aa1",
  "signatures": [
    {
      "R": "0xc669b62293629316d18e12cd90d5c4dc24000e13d31200c53e40ac8f01bf249e",
      "S": "0x62be831829631503e20cccd160fe1ec450950e6f982df16d83d3f6f948924aa1",
      "V": "0x7f5"
    }
  ],
  "status": "Submitted",
  "transactionHash": "0xd596aad17c6cf9f0fd9f3710652e00ebedd4f91cadc6cd856563e856492bd41c",
  "typeInt": 32
}

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developer forum.

Update AccountKey to AccountKeyRoleBased: Transaction Fee Delegation by User

Send a transaction for changing a Klaytn account key into a role-based key. The account key can be transformed into another key instead of the role-based key. Then, a user may have a fee-payer account pay for the transaction fee. For more details about types of Klaytn account keys, refer to the followings.

Updating a Klaytn account into a role-based account means transforming the account key to an AccountKeyRoleBased

To send the account update transaction, a user must send a transaction to Klaytn Node and pay the transaction fee. To call this API, you first need to create the Klaytn account who sends this transaction and the Klaytn account who pays the transaction fee (fee-payer) in Account Pool and Fee Payer Account Pool, each.

In this example, the fee payer account pays the transaction transmission fee, not the account who sends this transaction. For details about fee-delegation methods that KAS provides for you, please visit here.

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. For more details on creating an fee payer Account Pool, fee payer account, and selecting an fee payer account, refer to Getting Started.

API Request

Call the account update transaction transmission with fee delegation API. You can use the REST API or SDK (caver-js/caver-java) for calling the API. The following API call example updates a Klaytn account key into a role-based key (AccountKeyRoleBased, keyType:5 in KAS). If a Klaytn account has a role-based key, this account uses account keys for signing transactions according to its role

For details about keyType of Klaytn accountKey, please visit here.

There are 3 roles in Klaytn: regular transaction transmission (sending KLAY, deploying contracts, executing contracts, etc.), account update, and fee delegation. The following API call example updates the account to have the AccountKeyPublic (keyType:2) key for regular transaction transmission, AccountKeyFail (keyType:3) key for account update, and AccountKeyWeightedMultiSig(keyType:4) key for fee delegation. The fee delegation key is a multisig key with a threshold of two (2) with two account keys for signing transactions, with each key having a weight of one (1). This account was updated to have an AccountKeyFail as the account update role and consequently, the account key of this account will not be updated to any other type.

Enter keyType=3 (AccountKeyFail) to disregard specific roles when changing an account key into a role-based key.

Enter keyType=128 (AccountKeyNil) for role keys that must not be updated later when changing an account key into a role-based key.

curl --location --request PUT "https://wallet-api.klaytnapi.com/v2/tx/fd-user/account" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
--header "Content-Type: application/json" \
--data-raw "{
  "from": "0x5bb85d4032354E88020595AFAFC081C24098202e",
  "accountKey": {
    "keyType": 5,
    "key": [
      {
        "keyType": 3,
        "key": {}
      },
      {
        "keyType": 4,
        "key": {
          "threshold": 2,
          "weightedKeys": [
            {
              "weight": 1,
              "publicKey": "0xe4a01407460c1c03ac0c82fd84f303a699b210c0b054f4aff72ff7dcdf01512da5735a23ce1654b14680054a993441eae7c261983a56f8e0da61280758b5919"
            },
            {
              "weight": 1,
              "publicKey": "0x36f6355f5b532c3c1606f18fa2be7a16ae200c5159c8031dd25bfa389a4c9c066fdf9fc87a16ac359e66d9761445d5ccbb417fb7757a3f5209d713824596a50d"
            }
          ]
        }
      },
      {
        "keyType": 2,
        "key": "0x698a5769e28d0a2cf138a4f6533b158e90f1000a6331fe56aea628cf061f74f27cbef61d21ed45e6675e220b73912c76522bfae899ddde4eb25926617fb89d5d"
      }
    ]
  },
  "nonce": 0,
  "gasLimit": 1000000,
  "submit": true,
  "feePayer": "0x85B98485444c89880cD9C48807CEF727C296F2da",
  "feeRatio": 10
}"
  • submit: If it is false, a transaction is not sent and the RLP of signed transaction and the transaction information are returned.

  • fee_payer: If a user uses a separate transaction fee-payer account, he/she provides the account address to this parameter. Do not use the "feePayer" parameter to make KAS pay for the transaction fee first.

  • feeRatio: The ratio (1%~99%) of the transaction fee that a feePayer pays. The remaining fees will be directly paid by the account (from) that sends transactions to Klaytn.

    • This parameter is available for fee delegation through either a user fee-payer account or and KAS (KAS Global fee payer)

API Response

Here is the response of the account update transaction transmission with fee-delegation API.

{
  "accountKey": "0x05f8778203c0b84e04f84b02f848e301a103e4a01407460c1c03ac0c82fd84f303a699b210c0b054f4aff72ff7dcdf01512de301a10336f6355f5b532c3c1606f18fa2be7a16ae200c5159c8031dd25bfa389a4c9c06a302a103698a5769e28d0a2cf138a4f6533b158e90f1000a6331fe56aea628cf061f74f2",
  "feePayer": "0xe8ab1729ab614551021cf5cc22c0e037f5a82930",
  "from": "0x9c56b45b7443bc73f47234199982481c64807f78",
  "gasLimit": 1000000,
  "gasPrice": "0x5d21dba00",
  "nonce": 6,
  "rlp": "0x21f90143068505d21dba00830f4240949c56b45b7443bc73f47234199982481c64807f78b87a05f8778203c0b84e04f84b02f848e301a103e4a01407460c1c03ac0c82fd84f303a699b210c0b054f4aff72ff7dcdf01512de301a10336f6355f5b532c3c1606f18fa2be7a16ae200c5159c8031dd25bfa389a4c9c06a302a103698a5769e28d0a2cf138a4f6533b158e90f1000a6331fe56aea628cf061f74f2f847f8458207f5a0417123ce3a739bda66493ccf83bbc2b0e6a8a5ef181c04a9cbf76169abb106b6a024d596ce7e8f108012f26ec8853a1b9b65b4e670be8de7cbcbe73709f3a3179994e8ab1729ab614551021cf5cc22c0e037f5a82930f847f8458207f5a0b2917ba146947e7898f3df954ffde028cf11c5f23338b3eccc5e1ce20e73ec9ca05251179f052c064813fecae03ec07b121622f8352c599c12f4671784d6b94a03",
  "signatures": [
    {
      "R": "0x417123ce3a739bda66493ccf83bbc2b0e6a8a5ef181c04a9cbf76169abb106b6",
      "S": "0x24d596ce7e8f108012f26ec8853a1b9b65b4e670be8de7cbcbe73709f3a31799",
      "V": "0x7f5"
    }
  ],
  "status": "Submitted",
  "transactionHash": "0x6bd7c53520171aa9dfb535b62ac35e97a16798de7060eb844cbad6afbd847b86",
  "typeInt": 33
}

“typeInt” variable is a value for identifying the transaction type. For details about the types of transactions, please visit here.

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developer forum.

Update AccountKey to AccountKeyRoleBased: Transaction Fee Delegation by KAS

Send a transaction for changing a Klaytn account key into a role-based key. The account key can be transformed into another key instead of the role-based key. Then, a user may have a fee-payer account pay for the transaction fee. For more details about types of Klaytn account keys, refer to the followings.

Updating a Klaytn account into a role-based account means transforming the account key to an AccountKeyRoleBased

To send the account update transaction, a user must send a transaction to Klaytn Node and pay the transaction fee. To call this API, you first need to create an Account Pool and a Klaytn account who sends this transaction in that Account Pool. In this example, the KAS global fee payer account pays the transaction transmission fee, not the account who sends this transaction. This fee paid by KAS global fee payer instead of the Klaytn account who sent a transaction will later be charged to your KAS account. For details about fee-delegation methods that KAS provides for you, please visit here.

In this example, the fee payer account pays the transaction transmission fee, not the account who sends this transaction. For details about fee-delegation methods that KAS provides for you, please visit here.

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.

API Request

Call the account update transaction transmission with KAS GlobalFeePayer fee delegation API. You can use the REST API or SDK (caver-js/caver-java) for calling the API. The following API call example updates a Klaytn account key into a role-based key (AccountKeyRoleBased, keyType:5 in KAS). If a Klaytn account has a role-based key, this account uses account keys for signing transactions according to its role

For details about keyType of Klaytn accountKey, please visit here.

There are 3 roles in Klaytn: regular transaction transmission (sending KLAY, deploying contracts, executing contracts, etc.), account update, and fee delegation. The following API call example updates the account to have the AccountKeyPublic (keyType:2) key for regular transaction transmission, AccountKeyFail (keyType:3) key for account update, and AccountKeyWeightedMultiSig(keyType:4) key for fee delegation. The fee delegation key is a multisig key with a threshold of two (2) with two account keys for signing transactions, with each key having a weight of one (1). This account was updated to have an AccountKeyFail as the account update role and consequently, the account key of this account will not be updated to any other type.

Enter keyType=3 (AccountKeyFail) to disregard specific roles when changing an account key into a role-based key.

Enter keyType=128 (AccountKeyNil) for role keys that must not be updated later when changing an account key into a role-based key.

curl --location --request PUT "https://wallet-api.klaytnapi.com/v2/tx/fd/account" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
--header "Content-Type: application/json" \
--data-raw "{
  "from": "0x5bb85d4032354E88020595AFAFC081C24098202e",
  "accountKey": {
    "keyType": 5,
    "key": [
      {
        "keyType": 3,
        "key": {}
      },
      {
        "keyType": 4,
        "key": {
          "threshold": 2,
          "weightedKeys": [
            {
              "weight": 1,
              "publicKey": "0xe4a01407460c1c03ac0c82fd84f303a699b210c0b054f4aff72ff7dcdf01512da5735a23ce1654b14680054a993441eae7c261983a56f8e0da61280758b5919"
            },
            {
              "weight": 1,
              "publicKey": "0x36f6355f5b532c3c1606f18fa2be7a16ae200c5159c8031dd25bfa389a4c9c066fdf9fc87a16ac359e66d9761445d5ccbb417fb7757a3f5209d713824596a50d"
            }
          ]
        }
      },
      {
        "keyType": 2,
        "key": "0x698a5769e28d0a2cf138a4f6533b158e90f1000a6331fe56aea628cf061f74f27cbef61d21ed45e6675e220b73912c76522bfae899ddde4eb25926617fb89d5d"
      }
    ]
  },
  "nonce": 0,
  "gasLimit": 1000000,
  "submit": true,
  "feeRatio": 10
}"
  • submit: If it is false, a transaction is not sent and the RLP of signed transaction and the transaction information are returned.

  • feeRatio: The ratio (1%~99%) of the transaction fee that a feePayer pays. The remaining fees will be directly paid by the account (from) that sends transactions to Klaytn.

    • This parameter is available for fee delegation through either a user fee-payer account or and KAS (KAS Global fee payer)

API Response

Here is the response of the account update transaction transmission with KAS GlobalFeePayer fee-delegation API.

{
  "accountKey": "0x05f8778203c0b84e04f84b02f848e301a103e4a01407460c1c03ac0c82fd84f303a699b210c0b054f4aff72ff7dcdf01512de301a10336f6355f5b532c3c1606f18fa2be7a16ae200c5159c8031dd25bfa389a4c9c06a302a103698a5769e28d0a2cf138a4f6533b158e90f1000a6331fe56aea628cf061f74f2",
  "feePayer": "0x85b98485444c89880cd9c48807cef727c296f2da",
  "feeRatio": 10,
  "from": "0x9c56b45b7443bc73f47234199982481c64807f78",
  "gasLimit": 1000000,
  "gasPrice": "0x5d21dba00",
  "nonce": 6,
  "rlp": "0x21f90143068505d21dba00830f4240949c56b45b7443bc73f47234199982481c64807f78b87a05f8778203c0b84e04f84b02f848e301a103e4a01407460c1c03ac0c82fd84f303a699b210c0b054f4aff72ff7dcdf01512de301a10336f6355f5b532c3c1606f18fa2be7a16ae200c5159c8031dd25bfa389a4c9c06a302a103698a5769e28d0a2cf138a4f6533b158e90f1000a6331fe56aea628cf061f74f2f847f8458207f5a0417123ce3a739bda66493ccf83bbc2b0e6a8a5ef181c04a9cbf76169abb106b6a024d596ce7e8f108012f26ec8853a1b9b65b4e670be8de7cbcbe73709f3a3179994e8ab1729ab614551021cf5cc22c0e037f5a82930f847f8458207f5a0b2917ba146947e7898f3df954ffde028cf11c5f23338b3eccc5e1ce20e73ec9ca05251179f052c064813fecae03ec07b121622f8352c599c12f4671784d6b94a03",
  "signatures": [
    {
      "R": "0x417123ce3a739bda66493ccf83bbc2b0e6a8a5ef181c04a9cbf76169abb106b6",
      "S": "0x24d596ce7e8f108012f26ec8853a1b9b65b4e670be8de7cbcbe73709f3a31799",
      "V": "0x7f5"
    }
  ],
  "status": "Submitted",
  "transactionHash": "0x6bd7c53520171aa9dfb535b62ac35e97a16798de7060eb844cbad6afbd847b86",
  "typeInt": 33
}

“typeInt” variable is a value for identifying the transaction type. For details about the types of transactions, please visit here.

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developer forum.

Last updated