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.

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.

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

info

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

info

KAS also provides the Signing Transaction API.

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

info

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.

info

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

warning

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.

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.

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.

cURLJavaScriptJava
Copy
Copied
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
}"
Copy
Copied
// Update to AccountKeyLegay
const tx = {
  from: "0xA209b6D2DF012d63D798cB0BD0D7E0c53FddF649",
  accountKey: { keyType: 1 },
  gas: 1000000,
  submit: true,
};
const result = await caver.kas.wallet.requestAccountUpdate(tx);
// Update to AccountKeyPublic
const tx = {
  from: "0x948C163A29Fc31996CCb478Fe4bA17C891Dc6221",
  accountKey: {
    keyType: 2,
    key: "0x049e24b9f7b59730cd45cb8be47b32f88fb428798dde1d723e79f80f2c200cc8a2fcdaa340979c09dbaecad698825537c401624cf9ba1b7724650fe67056968c1c",
  },
  gas: 1000000,
  submit: true,
};
const result = await caver.kas.wallet.requestAccountUpdate(tx);
// Update to AccountKeyFail
const tx = {
  from: "0x7d0B0321FB82d70C3A2dDa1ab9112a6d58c94ADF",
  accountKey: { keyType: 3 },
  gas: 1000000,
  submit: true,
};
const result = await caver.kas.wallet.requestAccountUpdate(tx);
// Update to AccountKeyWeightedMultiSig
const tx = {
  from: "0x443f01B81ECC1e83dC46edA711F3D707511ef257",
  accountKey: {
    keyType: 4,
    key: {
      threshold: 2,
      weightedKeys: [
        {
          weight: 1,
          publicKey:
            "0x04a4dad8e41de69fdbf7c2d3b76eeeed47d449fd680d7dda0ae6346ac9e2c8de1637d8cbc4adbfa7b0f02ffedf39d8edb7dae983ba24a33fcdde37feedbe2a5cd7",
        },
        {
          weight: 1,
          publicKey:
            "0x0424a43009be004a10cf6d2d7ddb3fa31aa8e73bf540d8ad2a7a870c697981f3743f3691a45fc1c5ff13a7f521c5488b5a7926063b307c0def3d5f8f1f3a7fde0b",
        },
      ],
    },
  },
  gas: 1000000,
  submit: true,
};
const result = await caver.kas.wallet.requestAccountUpdate(tx);
// Update to AccountKeyRoleBased
const tx = {
  from: "0x7fe2434DA3B6Af4e23bB234a3972ab0bD9bad1bc",
  accountKey: {
    keyType: 5,
    key: [
      { keyType: 3, key: {} },
      {
        keyType: 4,
        key: {
          threshold: 2,
          weightedKeys: [
            {
              weight: 1,
              publicKey:
                "0x04abad100b699ea183959102c17d7792ba86b324548888ab4affb19bf814ea821066792679df7f1d8ce9075b93e29072d5600684a41a4614c1be9b3714302d9c4a",
            },
            {
              weight: 1,
              publicKey:
                "0x04c32ba77e5741783945a1ad7e2f201961d11e8e8192b104a2402e6307e9d7d9a77412693846eedc33083279e7e78e5619400bf194d8230ecec1f57cd14b791c2d",
            },
          ],
        },
      },
      {
        keyType: 2,
        key: "0x045505870ac8b7024e2b9eee23b8317eb79b796e44ece3fbb1d637d7a657bdbf0b3274216df59b1edf35bc94e4859357b5051cfaa8b5f659aae78a4d9bd2d8d6be",
      },
    ],
  },
  gas: 1000000,
  submit: true,
};
const result = await caver.kas.wallet.requestAccountUpdate(tx);
Copy
Copied
// Update to AccountKeyLegay
AccountUpdateTransactionRequest requestLegacy = new AccountUpdateTransactionRequest();
requestLegacy.setFrom("0x3723dc535131bba5108b6bfe6ccf2d2e512bdc91");
requestLegacy.setAccountKey(new KeyTypeLegacy());
requestLegacy.setSubmit(true);

TransactionResult result = caver.kas.wallet.requestAccountUpdate(requestLegacy);
System.out.println(result);

// Update to AccountKeyPublic
AccountUpdateTransactionRequest request = new AccountUpdateTransactionRequest();
request.setFrom("0x50f7ec091d363f9180f95921cbb2ad98c09a0822");
request.setAccountKey(new KeyTypePublic(account.getPublicKey()));
request.setSubmit(true);

TransactionResult result = caver.kas.wallet.requestAccountUpdate(request);
System.out.println(result);

// Update to AccountKeyFail
AccountUpdateTransactionRequest request = new AccountUpdateTransactionRequest();
request.setFrom("0xFdd009222A79179CDe24F15Da6022A9cF302fcD3");
request.setAccountKey(new KeyTypeFail());
request.setSubmit(true);

TransactionResult result = caver.kas.wallet.requestAccountUpdate(request);
System.out.println(result);

// Update to AccountKeyWeightedMultiSig
String publicKey1 = "0x048ab2585966fd8756e7565b9a6619a10f2b0c073825b66aafb9e474a03abc025bc27d9dd2304c90737160a206af7c938261d9efa0327474c858526104470f236b";
String publicKey2 = "0x0400df261720508aaeb0cd1ce01095e4a3fa88beef7300ab4663fa4769f74e0f4871258f438f11674f8d32c769d11e89eb7bcf7df382ceea0bc10a6a1e57e678a0";
String publicKey3 = "0x04b79fd28c45c3ca2ad6da97f8ba575605de16d249925a2321b8776f338d500eb2ce2b0530922564cb555a16435fc036f1eb007fc22ba9b9903cb6af0cb22f9ec3";

MultisigUpdateKey multisigUpdateKey = new MultisigUpdateKey();
multisigUpdateKey.setThreshold((long)2);
multisigUpdateKey.setWeightedKeys(
        Arrays.asList(createMultiSig(2, publicKey1),
                createMultiSig(1, publicKey2),
                createMultiSig(1, publicKey3))
);

KeyTypeMultiSig keyTypeMultiSig = new KeyTypeMultiSig(multisigUpdateKey);

AccountUpdateTransactionRequest request = new AccountUpdateTransactionRequest();
request.setFrom("0xba4C0E1f4f67EE60BD4c72933535BC3B5a4819a2");
request.setAccountKey(keyTypeMultiSig);
request.setSubmit(true);

TransactionResult result = caver.kas.wallet.requestAccountUpdate(request);
System.out.println(result);

// Update to AccountKeyRoleBased
KeyTypePublic txKey = new KeyTypePublic();
txKey.setKey("0x0439a181139c535990b24c10e7f5d7c6155b74098a674d6bbe92a8fa3ec8482557dba13d7381ddb9d66cbecc604d293f87f918ff341973cac2400c7e342bd244f2");

KeyTypePublic accountUpdateKey = new KeyTypePublic();
accountUpdateKey.setKey("0x0454e19cf077e460f251ccc9f3c23737dbf15ef9c593d1b132ce0d18f028a93df5cec8e06bde9fe5cd3a60c1a18728bd20998067f86ce602f968fcd0e24d9da1cf");

String publicKey1 = "0x048ab2585966fd8756e7565b9a6619a10f2b0c073825b66aafb9e474a03abc025bc27d9dd2304c90737160a206af7c938261d9efa0327474c858526104470f236b";
String publicKey2 = "0x0400df261720508aaeb0cd1ce01095e4a3fa88beef7300ab4663fa4769f74e0f4871258f438f11674f8d32c769d11e89eb7bcf7df382ceea0bc10a6a1e57e678a0";
String publicKey3 = "0x04b79fd28c45c3ca2ad6da97f8ba575605de16d249925a2321b8776f338d500eb2ce2b0530922564cb555a16435fc036f1eb007fc22ba9b9903cb6af0cb22f9ec3";

MultisigUpdateKey multisigUpdateKey = new MultisigUpdateKey();
multisigUpdateKey.setThreshold((long)2);
multisigUpdateKey.setWeightedKeys(
        Arrays.asList(createMultiSig(2, publicKey1),
                createMultiSig(1, publicKey2),
                createMultiSig(1, publicKey3))
);

KeyTypeMultiSig fdKey = new KeyTypeMultiSig(multisigUpdateKey);

KeyTypeRoleBased roleBasedUpdateKeyType = new KeyTypeRoleBased(Arrays.asList(txKey, accountUpdateKey, fdKey));

AccountUpdateTransactionRequest request = new AccountUpdateTransactionRequest();
request.setFrom("0xcf8b7b2c58805280ee4bb4d3fab17af8c6d9decf");
request.setAccountKey(roleBasedUpdateKeyType);
request.setGas(250000l);
request.setSubmit(true);

TransactionResult result = caver.kas.wallet.requestAccountUpdate(request);
System.out.println(result);
  • 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.

cURLJavaScriptJava
Copy
Copied
{
  "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
}
Copy
Copied
TransactionResult {
  from: '0x7fe2434da3b6af4e23bb234a3972ab0bd9bad1bc',
  gas: 1000000,
  gasPrice: '0x5d21dba00',
  nonce: 0,
  rlp: '0x20f8e5808505d21dba00830f4240947fe2434da3b6af4e23bb234a3972ab0bd9bad1bcb87a05f8778203c0b84e04f84b02f848e301a102abad100b699ea183959102c17d7792ba86b324548888ab4affb19bf814ea8210e301a103c32ba77e5741783945a1ad7e2f201961d11e8e8192b104a2402e6307e9d7d9a7a302a1025505870ac8b7024e2b9eee23b8317eb79b796e44ece3fbb1d637d7a657bdbf0bf847f8458207f6a0a7f12de6c2093f63d83f04d456446dfbd20c84473c68450ad874370fdde756c5a064bb0fabf09ef769a96bff45d1f74a108463409b3f4058a1f881d6ea9868e3aa',
  typeInt: 32,
  signatures: [
    Signature {
      R: '0xa7f12de6c2093f63d83f04d456446dfbd20c84473c68450ad874370fdde756c5',
      S: '0x64bb0fabf09ef769a96bff45d1f74a108463409b3f4058a1f881d6ea9868e3aa',
      V: '0x7f6'
    }
  ],
  status: 'Submitted',
  transactionHash: '0x6043beed2284b8223edef80c0bc562af36be300fb83be0377859a4d2968823cb',
  accountKey: '0x05f8778203c0b84e04f84b02f848e301a102abad100b699ea183959102c17d7792ba86b324548888ab4affb19bf814ea8210e301a103c32ba77e5741783945a1ad7e2f201961d11e8e8192b104a2402e6307e9d7d9a7a302a1025505870ac8b7024e2b9eee23b8317eb79b796e44ece3fbb1d637d7a657bdbf0b'
}
Copy
Copied
class TransactionResult {
    from: 0x50f7ec091d363f9180f95921cbb2ad98c09a0822
    gas: 250000
    gasPrice: 0x5d21dba00
    input: null
    nonce: 0
    rlp: 0x20f88d808505d21dba00830186a09450f7ec091d363f9180f95921cbb2ad98c09a0822a302a103aa8fe5f10690ddbc02cc69f6777b6e8d5e0fe5a21a791b63899d7bb1395c6813f847f8458207f5a00154c1b29101d07513215222bbc113f4825c1bebe3f5a9c8c395c1cb9c5b16e3a053c32a15b14d753eed6bec46db48fa04ec31ae307d2a76445dea2ab268917eb0
    signatures: [class Signature {
        R: 0x154c1b29101d07513215222bbc113f4825c1bebe3f5a9c8c395c1cb9c5b16e3
        S: 0x53c32a15b14d753eed6bec46db48fa04ec31ae307d2a76445dea2ab268917eb0
        V: 0x7f5
    }]
    status: Submitted
    to: null
    transactionHash: 0x52eb902ed67ca67fea6f7de5de6a2999a217283667c92061123242a9436aefcd
    typeInt: 32
    value: null
    code: null
    message: null
    transactionId: null
    accountKey: 0x02a103aa8fe5f10690ddbc02cc69f6777b6e8d5e0fe5a21a791b63899d7bb1395c6813
}

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developers 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.

info

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.

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

info

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.

info

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

info

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

cURLJavaScriptJava
Copy
Copied
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
}"
Copy
Copied
// For the transaction format for each AccountKey type, refer to the chapter "Update AccountKey to AccountKeyWeightedMultiSig: Direct Payment of Transaction Fee" at the top of the page.
const tx = {
  from: "0xA3E79115c78bbC8eFdDA2a17a4Bdb48Dca2b5333",
  accountKey: {
    keyType: 4,
    key: {
      threshold: 2,
      weightedKeys: [
        {
          weight: 1,
          publicKey:
            "0x04371334d038d983f3b560b2534385138ffaf69cf1aef039b268ef69c1736ec6544bc9a04598ca5ba4c2e75e648c6d8e6a892b33662bfe680544daa53c75b06e35",
        },
        {
          weight: 1,
          publicKey:
            "0x041640a55aed2c871f8896a263b378ce73e323254de9173fd071bb29aa8d4c52855ed8b4164db5db21d3c4e3baed2611d9d34932f36b6096086eee0c690417fb97",
        },
      ],
    },
  },
  gas: 1000000,
  feePayer: "0x44Ee3906a7a2007762E9d706dF6E4eF63FA1edA8",
  submit: true,
};
const result = await caver.kas.wallet.requestFDAccountUpdatePaidByUser(tx);
Copy
Copied
String publicKey1 = "0x0459b8b2f0297f8fc96326254c4b6dc706c53119626ab1a524b629af9e7bcbe153b81c6a4870e76ca6533a9ac10c879a19cbe415fcb481dcd13ddf42ecbc877c11";
String publicKey2 = "0x0471ed41581d6cd86499cfa0980db20b86c9a5028b5b2fbce6eef92a297f3ba96f3bfda8b42a45a43868dd4308f2fa8e068d25701ce6c53bbddc6c6e7bd1d7049c";
String publicKey3 = "0x04508fd5b298583115eb69b445d13c1dc5ccf96a73e1135bb52f4852b35206468c3b21dcbae4560ef34638632827539e8a770dbc922b9e7e1bd5f30c3dd84bb19b";

MultisigUpdateKey multisigUpdateKey = new MultisigUpdateKey();
multisigUpdateKey.setThreshold((long)2);
multisigUpdateKey.setWeightedKeys(
        Arrays.asList(createMultiSig(2, publicKey1),
                createMultiSig(1, publicKey2),
                createMultiSig(1, publicKey3))
);

KeyTypeMultiSig keyTypeMultiSig = new KeyTypeMultiSig(multisigUpdateKey);

FDAccountUpdateTransactionRequest request = new FDAccountUpdateTransactionRequest();
request.setFrom("0x08Ba68AC55396e291adD39292E0280b08342FE2b");
request.setAccountKey(keyTypeMultiSig);
request.setFeePayer("0x31d845Ac80A0B2a38f6267CabcF34F8fA9DcD2B7");
request.setSubmit(true);

FDTransactionResult result = caver.kas.wallet.requestFDAccountUpdatePaidByUser(request);
System.out.println(result);
  • 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.

cURLJavaScriptJava
Copy
Copied
{
  "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
}
Copy
Copied
FDTransactionResult {
  feePayer: '0x44ee3906a7a2007762e9d706df6e4ef63fa1eda8',
  from: '0xa3e79115c78bbc8efdda2a17a4bdb48dca2b5333',
  gas: 1000000,
  gasPrice: '0x5d21dba00',
  nonce: 0,
  rlp: '0x21f90117808505d21dba00830f424094a3e79115c78bbc8efdda2a17a4bdb48dca2b5333b84e04f84b02f848e301a103371334d038d983f3b560b2534385138ffaf69cf1aef039b268ef69c1736ec654e301a1031640a55aed2c871f8896a263b378ce73e323254de9173fd071bb29aa8d4c5285f847f8458207f5a072332d0c98a364702d5da44f75ea2945d030cd6d540221433248dacf7d7cc543a01c689fe90dbc086c88a7faf9d160a544de711c905633c252b4d825e7c7396a189444ee3906a7a2007762e9d706df6e4ef63fa1eda8f847f8458207f6a052ba46bc1616929027ba54df4a736bd021ba4603c3a3bb19d6b4e4150bc4bf3fa077fa110b70b964beb79e895a5f9476a8b594b0fce2912c51c22a97c1e482b950',
  typeInt: 33,
  signatures: [
    Signature {
      R: '0x72332d0c98a364702d5da44f75ea2945d030cd6d540221433248dacf7d7cc543',
      S: '0x1c689fe90dbc086c88a7faf9d160a544de711c905633c252b4d825e7c7396a18',
      V: '0x7f5'
    }
  ],
  status: 'Submitted',
  transactionHash: '0x9d2fd76c3962f013a9f81f7a03f3237b09efd465a81b60ebbcd476b4472e9fe3',
  accountKey: '0x04f84b02f848e301a103371334d038d983f3b560b2534385138ffaf69cf1aef039b268ef69c1736ec654e301a1031640a55aed2c871f8896a263b378ce73e323254de9173fd071bb29aa8d4c5285'
}
Copy
Copied
class FDTransactionResult {
    feePayer: 0x31d845ac80a0b2a38f6267cabcf34f8fa9dcd2b7
    from: 0xdd9f780ef810138a9625071b45211b00a76c9c43
    gas: 1000000
    gasPrice: 0x5d21dba00
    input: null
    nonce: 0
    rlp: 0x21f9013b808505d21dba00830186a094dd9f780ef810138a9625071b45211b00a76c9c43b87204f86f02f86ce302a10359b8b2f0297f8fc96326254c4b6dc706c53119626ab1a524b629af9e7bcbe153e301a10271ed41581d6cd86499cfa0980db20b86c9a5028b5b2fbce6eef92a297f3ba96fe301a103508fd5b298583115eb69b445d13c1dc5ccf96a73e1135bb52f4852b35206468cf847f8458207f6a0942b8febf7814a978d50144a086fb8266d6946f2b00d7d94a162245f8606b52ca0129d39b1d9f957ba61f7d2ead87dbc8eeeedf758d4846385a0ad66e21e67f5419431d845ac80a0b2a38f6267cabcf34f8fa9dcd2b7f847f8458207f6a079da3d049da82db02191c3df171af460043f13cd480b029d35d77a36dede494fa009eb920ba1c809d5a06912f09b0888ac92abd32ed08dba987f85dedd91d80bcd
    signatures: [class Signature {
        R: 0x942b8febf7814a978d50144a086fb8266d6946f2b00d7d94a162245f8606b52c
        S: 0x129d39b1d9f957ba61f7d2ead87dbc8eeeedf758d4846385a0ad66e21e67f541
        V: 0x7f6
    }]
    status: Submitted
    to: null
    transactionHash: 0x3d0b8802d1c16655115803f23f4866c9e0fb5d18a02862fb4f979a1799b43bd8
    typeInt: 33
    value: null
    feeRatio: null
    transactionId: null
    accountKey: 0x04f86f02f86ce302a10359b8b2f0297f8fc96326254c4b6dc706c53119626ab1a524b629af9e7bcbe153e301a10271ed41581d6cd86499cfa0980db20b86c9a5028b5b2fbce6eef92a297f3ba96fe301a103508fd5b298583115eb69b445d13c1dc5ccf96a73e1135bb52f4852b35206468c
}
info

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

info

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.

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.

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

info

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.

info

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

info

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

cURLJavaScriptJava
Copy
Copied
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
}"
Copy
Copied
// For the transaction format for each AccountKey type, refer to the chapter "Update AccountKey to AccountKeyWeightedMultiSig: Direct Payment of Transaction Fee" at the top of the page.
const tx = {
  from: "0xd19CeD8B6CA1d5924ECaf4321c1C8Fae64C2ADf8",
  accountKey: {
    keyType: 4,
    key: {
      threshold: 2,
      weightedKeys: [
        {
          weight: 1,
          publicKey:
            "0x04371334d038d983f3b560b2534385138ffaf69cf1aef039b268ef69c1736ec6544bc9a04598ca5ba4c2e75e648c6d8e6a892b33662bfe680544daa53c75b06e35",
        },
        {
          weight: 1,
          publicKey:
            "0x041640a55aed2c871f8896a263b378ce73e323254de9173fd071bb29aa8d4c52855ed8b4164db5db21d3c4e3baed2611d9d34932f36b6096086eee0c690417fb97",
        },
      ],
    },
  },
  gas: 1000000,
  submit: true,
};
const result =
  await caver.kas.wallet.requestFDAccountUpdatePaidByGlobalFeePayer(tx);
Copy
Copied
String publicKey1 = "0x04a9f0fbeab8c415e560c12266c51ecd90c71dd16ca97a99d3fd55f2eaf4698a1a68a942c0d25bd27f3d4e5604b394fb197b69091972d70d35927896633aae140c";
String publicKey2 = "0x0432ac2fa7aa17035999f9dc2b151d9b551a85e4acb6c61e2e4905bafcf64b5fb29f59f12d631a31a3fb32c9913945cfc623db4714471a7ceee4c2d39c99922691";
String publicKey3 = "0x040f381470965e1c939e792b583ae221fd5fb7524c25bc07221e2a80f71431ed2a2e859dfb641aa8c809d5e649d0b5fc3ba407369aa7e67f72d63d5a253f143048";

MultisigUpdateKey multisigUpdateKey = new MultisigUpdateKey();
multisigUpdateKey.setThreshold((long)2);
multisigUpdateKey.setWeightedKeys(
        Arrays.asList(createMultiSig(2, publicKey1),
                createMultiSig(1, publicKey2),
                createMultiSig(1, publicKey3))
);

KeyTypeMultiSig keyTypeMultiSig = new KeyTypeMultiSig(multisigUpdateKey);

FDAccountUpdateTransactionRequest request = new FDAccountUpdateTransactionRequest();
request.setFrom("0xEFBB861E098641550e5b1732454b1dD7BA008259");
request.setAccountKey(keyTypeMultiSig);
request.setSubmit(true);

FDTransactionResult result = caver.kas.wallet.requestFDAccountUpdatePaidByGlobalFeePayer(request);
System.out.println(result);
  • 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.

cURLJavaScriptJava
Copy
Copied
{
  "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
}
Copy
Copied
FDTransactionResult {
  feePayer: '0x1b71a63903e35371e2fc41c6012effb99b9a2c0f',
  from: '0xd19ced8b6ca1d5924ecaf4321c1c8fae64c2adf8',
  gas: 1000000,
  gasPrice: '0x5d21dba00',
  nonce: 0,
  rlp: '0x21f90117808505d21dba00830f424094d19ced8b6ca1d5924ecaf4321c1c8fae64c2adf8b84e04f84b02f848e301a103371334d038d983f3b560b2534385138ffaf69cf1aef039b268ef69c1736ec654e301a1031640a55aed2c871f8896a263b378ce73e323254de9173fd071bb29aa8d4c5285f847f8458207f5a0f70cfcc8c3354eec1b6ed248bd59f05501f18507fd00e546d17f3925d277fdaaa0295ee51197017cf9512c7d5ca93d5cf504a866533b55347002bed2c7960ab2e9941b71a63903e35371e2fc41c6012effb99b9a2c0ff847f8458207f5a0c4803710b2856e75aef99192911d386ffd25c23825835f5cc649abd63f664be0a020e65737788dc2006144891d1e97e60200b2163e6a8b890693a87716b0126e5a',
  typeInt: 33,
  signatures: [
    Signature {
      R: '0xf70cfcc8c3354eec1b6ed248bd59f05501f18507fd00e546d17f3925d277fdaa',
      S: '0x295ee51197017cf9512c7d5ca93d5cf504a866533b55347002bed2c7960ab2e9',
      V: '0x7f5'
    }
  ],
  status: 'Submitted',
  transactionHash: '0x53fcc4efe8a7fb7b251233564043dd8c2fdedea7b7d42d750a1cc4aead208c11',
  accountKey: '0x04f84b02f848e301a103371334d038d983f3b560b2534385138ffaf69cf1aef039b268ef69c1736ec654e301a1031640a55aed2c871f8896a263b378ce73e323254de9173fd071bb29aa8d4c5285'
}
Copy
Copied
class FDTransactionResult {
    feePayer: 0x1b71a63903e35371e2fc41c6012effb99b9a2c0f
    from: 0xefbb861e098641550e5b1732454b1dd7ba008259
    gas: 1000000
    gasPrice: 0x5d21dba00
    input: null
    nonce: 0
    rlp: 0x21f9013b808505d21dba00830186a094efbb861e098641550e5b1732454b1dd7ba008259b87204f86f02f86ce302a102a9f0fbeab8c415e560c12266c51ecd90c71dd16ca97a99d3fd55f2eaf4698a1ae301a10332ac2fa7aa17035999f9dc2b151d9b551a85e4acb6c61e2e4905bafcf64b5fb2e301a1020f381470965e1c939e792b583ae221fd5fb7524c25bc07221e2a80f71431ed2af847f8458207f6a0d9272e8f511ffc30ebb77c968ca3fedc2a62e436fcdaba96c0d05cdbdeebda24a05cf0adb9b257a08ac2e3232b9943e60e5c3faf16c87f239258ed9ce199d64a36941b71a63903e35371e2fc41c6012effb99b9a2c0ff847f8458207f5a0ec3596ab6196a3fc5a027eea06758e9afa0a24b63c1aac06004afd377e878aaca00846ed9051ccf56b74317b855e225ff9ef89136557049fc6124f0f2f45459f74
    signatures: [class Signature {
        R: 0xd9272e8f511ffc30ebb77c968ca3fedc2a62e436fcdaba96c0d05cdbdeebda24
        S: 0x5cf0adb9b257a08ac2e3232b9943e60e5c3faf16c87f239258ed9ce199d64a36
        V: 0x7f6
    }]
    status: Submitted
    to: null
    transactionHash: 0x35cd6e962aacdde5b1188267f0fc81b31fdd42b9c9d9f7ee31f7b9ee82be6510
    typeInt: 33
    value: null
    feeRatio: null
    transactionId: null
    accountKey: 0x04f86f02f86ce302a102a9f0fbeab8c415e560c12266c51ecd90c71dd16ca97a99d3fd55f2eaf4698a1ae301a10332ac2fa7aa17035999f9dc2b151d9b551a85e4acb6c61e2e4905bafcf64b5fb2e301a1020f381470965e1c939e792b583ae221fd5fb7524c25bc07221e2a80f71431ed2a
}
info

"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 Developers Forum.