๊ณ„์ • ์—…๋ฐ์ดํŠธ

Wallet API๋ฅผ ํ™œ์šฉํ•œ ๊ณ„์ • ํ‚ค ์—…๋ฐ์ดํŠธ ํŠธ๋žœ์žญ์…˜์„ Klaytn์— ์ „์†กํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•ˆ๋‚ดํ•ฉ๋‹ˆ๋‹ค.

ํŠœํ† ๋ฆฌ์–ผ์— ์•ž์„œ

  • API ํ˜ธ์ถœ์— ์‚ฌ์šฉ๋˜๋Š” x-chain-id ๊ฐ’์€ 8217(Cypress) ๋˜๋Š” 1001(Baobab)์ž…๋‹ˆ๋‹ค.
  • API ํ˜ธ์ถœ์— ํ•„์š”ํ•œ ํ•„์ˆ˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋Š” ๊ฐ ์˜ˆ์‹œ์— ์„ค๋ช…๋ฉ๋‹ˆ๋‹ค.

API ํ˜ธ์ถœ ์‹œ ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•ด์•ผ ํ•˜๋Š” ๊ฐ’์€ ์ค‘๊ด„ํ˜ธ 1๊ฐœ({})๋กœ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•ด์•ผ ํ•˜๋Š” ๊ฐ’์€ ์•„๋ž˜ ํ…Œ์ด๋ธ”๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

ํ•ญ๋ชฉ ๊ฐ’ ๋น„๊ณ 
chain-id 8217 ๋˜๋Š” 1001 Cypress(Klaytn ๋ฉ”์ธ๋„ท) ๋˜๋Š” Baobab(Klaytn ํ…Œ์ŠคํŠธ๋„ท)
secret-access-key ์ธ์ฆ ๋น„๋ฐ€๋ฒˆํ˜ธ KAS Console > [Security] > [Credential]์—์„œ ๋ฐœ๊ธ‰๋ฐ›์€ secretAccessKey
krn (optional) ๊ณ„์ • ์ €์žฅ์†Œ์˜ ID ๊ธฐ๋ณธ ๊ณ„์ • ์ €์žฅ์†Œ ์‚ฌ์šฉ ์‹œ ๋ถˆํ•„์š”

API ์ธ์ฆ ํ‚ค๊ฐ€ ์žˆ์œผ๋ฉด ๋ชจ๋“  KAS ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ Wallet API๋ฅผ ํ˜ธ์ถœํ•ด ๋งŒ๋“  Klaytn ๊ณ„์ •์— ๋Œ€ํ•œ ๋ชจ๋“  ๊ถŒํ•œ์„ ์†Œ์œ ํ•ฉ๋‹ˆ๋‹ค. ๋ชจ๋“  ๊ถŒํ•œ์—๋Š” Klaytn ๊ณ„์ •์˜ ์ž์‚ฐ(KLAY ๋“ฑ) ์ด๋™์ด๋‚˜ ํŠธ๋žœ์žญ์…˜ ์ „์†ก ๋ฐ ์‹คํ–‰ ๊ถŒํ•œ์ด ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. ๋งŒ์•ฝ API ์ธ์ฆ ํ‚ค์— ํƒ€์ธ์ด ์ ‘๊ทผํ•œ๋‹ค๋ฉด Klaytn ๊ณ„์ • ๊ถŒํ•œ์„ ํƒˆ์ทจ๋‹นํ•ด ์›์น˜ ์•Š๋Š” ํŠธ๋žœ์žญ์…˜์ด ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

danger

KAS/Klaytn ๊ณ„์ • ๋ณด์•ˆ์„ ์œ„ํ•ด KAS API ์ธ์ฆ ํ‚ค(Secret Access Key)๋ฅผ ํƒ€์ธ๊ณผ ํ•จ๋ถ€๋กœ ๊ณต์œ ํ•˜์ง€ ๋ง๊ณ  ์ฃผ์˜ํ•ด ๊ด€๋ฆฌํ•˜์‹ญ์‹œ์˜ค.

Klaytn ๊ณ„์ • ์—…๋ฐ์ดํŠธ

Klaytn ๊ณ„์ •์„ ๋‹ค๋ฅธ ๊ณ„์ •์œผ๋กœ ์—…๋ฐ์ดํŠธํ•œ๋‹ค๋Š” ๊ฒƒ์€, ๊ณ„์ • ํ‚ค๋ฅผ ๋‹ค๋ฅธ ํ‚ค๋กœ ๋ฐ”๊พผ๋‹ค๋Š” ๊ฒƒ๊ณผ ๊ฐ™์€ ๋œป์ž…๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ๋ ˆ๊ฑฐ์‹œ ๊ณ„์ •์„ ๋‹ค์ค‘ ์„œ๋ช… ๊ณ„์ •์œผ๋กœ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๊ฒƒ์€ ๋‚ด Klaytn ๊ณ„์ • ํ‚ค๋ฅผ ๋ ˆ๊ฑฐ์‹œ ํ‚ค์—์„œ ๋‹ค์ค‘ ์„œ๋ช… ํ‚ค๋กœ ๋ฐ”๊พผ๋‹ค๋Š” ๊ฒƒ๊ณผ ๋™์ผํ•ฉ๋‹ˆ๋‹ค.

info

Klaytn ๊ณ„์ •๊ณผ ๊ณ„์ • ํ‚ค์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋‹ค์Œ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

  • Klaytn ๊ณ„์ • ํ‚ค ๋ชจ๋“  ํŠธ๋žœ์žญ์…˜์€ ์„œ๋ช…์„ ๋ฐ›์•„์•ผ Klaytn์— ์ „์†ก๋˜๊ณ , Klaytn์— ์ „์†ก๋˜์–ด์•ผ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. Klaytn ๊ณ„์ • ํ‚ค๋Š” ํŠธ๋žœ์žญ์…˜์— ์„œ๋ช…ํ•  ๋•Œ ์‚ฌ์šฉ๋˜์ง€๋งŒ, KAS๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์—ฌ๋Ÿฌ๋ถ„์€ ์ผ๋ฐ˜์ ์ธ ์ƒํ™ฉ(KLAY ์ „์†ก, ์Šค๋งˆํŠธ ์ปจํŠธ๋ž™ํŠธ ๋ฐฐํฌ ๋“ฑ)์—์„œ๋Š” ์„œ๋ช…ํ•˜์ง€ ์•Š๊ณ ๋„ ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ ์ผ๋ฐ˜์ ์ด์ง€ ์•Š๊ณ  ํŠน์ˆ˜ํ•œ ์ƒํ™ฉ์ด๋ž€ 1๊ฐœ์˜ ํŠธ๋žœ์žญ์…˜์— ์—ฌ๋Ÿฌ ๊ณ„์ •์˜ ์„œ๋ช…์„ ๋ฐ›์•„์•ผ ํ•˜๊ฑฐ๋‚˜(๋‹ค์ค‘ ์„œ๋ช…), KAS์—์„œ ๊ด€๋ฆฌํ•˜๋Š” Klaytn ๊ณ„์ • ์„œ๋ช…์ด ์•„๋‹Œ KAS ์™ธ๋ถ€ Klaytn ๊ณ„์ • ์„œ๋ช…์ด ํ•„์š”ํ•  ๋•Œ(์™ธ๋ถ€ ์„œ๋ช…)๋ฅผ ๋งํ•ฉ๋‹ˆ๋‹ค.
info

KAS์—์„œ๋„ ํŠธ๋žœ์žญ์…˜์— ์„œ๋ช…ํ•˜๋Š” API๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

ํŠธ๋žœ์žญ์…˜ ์„œ๋ช…์— ์‚ฌ์šฉํ•˜๋Š” Klaytn ๊ณ„์ • ํ‚ค์—๋Š” ํฌ๊ฒŒ ์ผ๋ฐ˜์ ์ธ ๊ณต๊ฐœํ‚ค, ๋‹ค์ค‘ ์„œ๋ช…์šฉ ํ‚ค, ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

info

Klaytn ํ‚ค ํƒ€์ž…(keyType)์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋‹ค์Œ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

๊ณ„์ • ํ‚ค๋ฅผ ๋‹ค์ค‘ ์„œ๋ช… ํ‚ค๋กœ ๋ณ€๊ฒฝ

์—ฌ๊ธฐ์„œ ์†Œ๊ฐœํ•˜๋Š” ๋‚ด์šฉ์€ ํŠธ๋žœ์žญ์…˜ ์ „์†ก ๊ณ„์ •์ด ์ „์†ก ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ๋ถ€๋‹ดํ•  ๋•Œ ๊ณ„์ • ํ‚ค๋ฅผ ๋‹ค์ค‘ ์„œ๋ช… ํ‚ค๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.

๋จผ์ € Klaytn ๊ณ„์ • ํ‚ค๋ฅผ ๋‹ค์ค‘ ์„œ๋ช… ํ‚ค๋กœ ๋ฐ”๊พธ๋Š” ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค. ๊ณ„์ • ํ‚ค๋ฅผ ๋‹ค์ค‘ ์„œ๋ช… ํ‚ค ์™ธ์— ๋‹ค๋ฅธ ํ‚ค๋กœ๋„ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Klaytn ๊ณ„์ • ํ‚ค ์ข…๋ฅ˜๋Š” Klaytn Docs์˜ ๊ณ„์ •์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

info

Klaytn ๊ณ„์ •์„ ๋‹ค์ค‘ ์„œ๋ช…(MultiSig) ๊ณ„์ •์œผ๋กœ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๊ฒƒ์€ ๊ณ„์ • ํ‚ค๋ฅผ AccountKeyWeightedMultiSig๋กœ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๊ฒƒ๊ณผ ๋™์ผํ•ฉ๋‹ˆ๋‹ค.

warning

๋‹ค์ค‘ ์„œ๋ช… ํ‚ค๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ๊ฐ ํ‚ค๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ณ„์ •๋“ค์€ ๋ชจ๋‘ ๊ฐ™์€ ๊ณ„์ • ์ €์žฅ์†Œ์— ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

info

KAS SDK(caver-js/caver-java extension) ์„ค์น˜, ์‹คํ–‰์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ KAS SDK๋ฅผ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.
๊ณ„์ • ์ €์žฅ์†Œ ์ƒ์„ฑ, ๊ณ„์ • ์ƒ์„ฑ, ๊ณ„์ • ์„ ํƒ์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ Getting Started๋ฅผ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

API ํ˜ธ์ถœ

๊ณ„์ •์„ ์—…๋ฐ์ดํŠธํ•˜๋ ค๋ฉด Klaytn Node์— ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋‚ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋•Œ ํŠธ๋žœ์žญ์…˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ง€๋ถˆํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์•„๋ž˜ ์˜ˆ์‹œ๋ฅผ ๋”ฐ๋ผ ๊ณ„์ • ์—…๋ฐ์ดํŠธ ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋‚ด๋ฉด ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋‚ด๋Š” ๊ณ„์ •์ด ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ง์ ‘ ์ง€๋ถˆํ•ฉ๋‹ˆ๋‹ค. API๋ฅผ ํ˜ธ์ถœํ•˜๊ธฐ ์œ„ํ•ด ๊ณ„์ • ์ €์žฅ์†Œ์™€ ๊ณ„์ •์„ ์ƒ์„ฑํ•˜๊ณ  ์‚ฌ์šฉํ•  ๊ณ„์ •์„ ์„ ํƒํ•˜์„ธ์š”.

๋‚ด ๊ณ„์ • ์ •๋ณด, ์ƒˆ๋กญ๊ฒŒ ์‚ฌ์šฉํ•  ํ‚ค ์ •๋ณด๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ๊ณ„์ • ์—…๋ฐ์ดํŠธ ํŠธ๋žœ์žญ์…˜ ์ „์†ก API๋ฅผ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค. API ํ˜ธ์ถœ ์‹œ REST API ๋˜๋Š” SDKs(caver-js, caver-java extensions)๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜ API ํ˜ธ์ถœ ์˜ˆ์‹œ๋Š”, Klaytn ๊ณ„์ •์„ ๊ธฐ์ค€์น˜๊ฐ€ 3์ด๊ณ  ํŠธ๋žœ์žญ์…˜ ์„œ๋ช…์šฉ ํ‚ค๊ฐ€ 4๊ฐœ์ด๋ฉฐ ๊ฐ ํ‚ค๋Š” ๊ฐ€์ค‘์น˜ 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 : false์ด๋ฉด ํŠธ๋žœ์žญ์…˜์ด ์ „์†ก๋˜์ง€ ์•Š๊ณ , ์„œ๋ช…๋œ ํŠธ๋žœ์žญ์…˜ RLP์™€ ํŠธ๋žœ์žญ์…˜ ์ •๋ณด๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

API ์‘๋‹ต

๊ณ„์ • ์—…๋ฐ์ดํŠธ ํŠธ๋žœ์žญ์…˜ ์ „์†ก 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: 1000000
    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
}

์ด API์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋‹ค์Œ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.
์ด ๋ฌธ์„œ ํ˜น์€ KAS์— ๊ด€ํ•œ ๋ฌธ์˜๋Š” ๊ฐœ๋ฐœ์ž ํฌ๋Ÿผ์„ ๋ฐฉ๋ฌธํ•ด ๋„์›€ ๋ฐ›์œผ์‹ญ์‹œ์˜ค.

๊ณ„์ • ํ‚ค๋ฅผ ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค๋กœ ๋ณ€๊ฒฝ 1

์—ฌ๊ธฐ์„œ ์†Œ๊ฐœํ•˜๋Š” ๋‚ด์šฉ์€ ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๊ณ„์ •์ด ํŠธ๋žœ์žญ์…˜ ์ „์†ก ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ๋ถ€๋‹ดํ•  ๋•Œ ๊ณ„์ • ํ‚ค๋ฅผ ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. Klaytn ๊ณ„์ • ํ‚ค๋ฅผ ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค๋กœ ๋ฐ”๊พธ๋Š” ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค. ๊ณ„์ • ํ‚ค๋ฅผ ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค ์™ธ์— ๋‹ค๋ฅธ ํ‚ค๋กœ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์œผ๋ฉฐ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๊ณ„์ •์ด ์ด ํŠธ๋žœ์žญ์…˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ๋Œ€๋‚ฉํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Klaytn ๊ณ„์ • ํ‚ค ์ข…๋ฅ˜๋Š” ๋‹ค์Œ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

info

Klaytn ๊ณ„์ •์„ ์—ญํ•  ๊ธฐ๋ฐ˜ ๊ณ„์ •์œผ๋กœ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๊ฒƒ์€ ๊ณ„์ • ํ‚ค๋ฅผ AccountKeyRoleBased๋กœ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๊ฒƒ๊ณผ ๋™์ผํ•ฉ๋‹ˆ๋‹ค.

KAS๋กœ ๊ณ„์ • ์—…๋ฐ์ดํŠธ ํŠธ๋žœ์žญ์…˜์„ ์ „์†กํ•˜๋ ค๋ฉด Klaytn Node์— ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋‚ด์•ผ ํ•˜๋ฉฐ, ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋‚ด๋ ค๋ฉด ํŠธ๋žœ์žญ์…˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ง€๋ถˆํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. API๋ฅผ ํ˜ธ์ถœํ•˜๋ ค๋ฉด ๊ณ„์ • ์ €์žฅ์†Œ, ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๊ณ„์ • ์ €์žฅ์†Œ์— ๊ฐ๊ฐ ๊ณ„์ •, ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๊ณ„์ •์„ ์ƒ์„ฑํ•˜๊ณ  ์‚ฌ์šฉํ•  ๊ณ„์ •, ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๊ณ„์ •์„ ์„ ํƒํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์ด ์˜ˆ์‹œ๋ฅผ ๋”ฐ๋ผ ๊ณ„์ • ์—…๋ฐ์ดํŠธ ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋‚ด๋ฉด, ๋ณด๋‚ด๋Š” ๊ณ„์ •(Account)์ด ์•„๋‹ˆ๋ผ ๋‹ค๋ฅธ ๊ณ„์ •(์—ฌ๋Ÿฌ๋ถ„์˜ ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๊ณ„์ •)์ด ์ด ํŠธ๋žœ์žญ์…˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ๋Œ€์‹  ๋ถ€๋‹ดํ•ฉ๋‹ˆ๋‹ค. KAS์—์„œ ์ œ๊ณตํ•˜๋Š” ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๋ฐฉ์‹์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋‹ค์Œ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

info

KAS SDK(caver-js/caver-java extension) ์„ค์น˜, ์‹คํ–‰์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ KAS SDK๋ฅผ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.
๊ณ„์ • ์ €์žฅ์†Œ ์ƒ์„ฑ, ๊ณ„์ • ์ƒ์„ฑ, ๊ณ„์ • ์„ ํƒ์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ Getting Started๋ฅผ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.
์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๊ณ„์ • ์ €์žฅ์†Œ ์ƒ์„ฑ, FeePayerAccount ์ƒ์„ฑ, FeePayerAccount ์„ ํƒ์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ Getting Started๋ฅผ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

API ํ˜ธ์ถœ

์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๋ฐฉ์‹ ๊ณ„์ • ์—…๋ฐ์ดํŠธ ํŠธ๋žœ์žญ์…˜ ์ „์†ก API๋ฅผ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค. API ํ˜ธ์ถœ ์‹œ REST API ๋˜๋Š” SDKs(caver-js, caver-java extensions)๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜ API ํ˜ธ์ถœ ์˜ˆ์‹œ๋Š”, Klaytn ๊ณ„์ •์„ ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค(AccountKeyRoleBased, KAS์—์„œ๋Š” keyType:5)๋กœ ์—…๋ฐ์ดํŠธํ•ฉ๋‹ˆ๋‹ค. ์–ด๋–ค Klaytn ๊ณ„์ •์ด ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค๋ฅผ ๊ฐ€์ง€๋ฉด ์ด ๊ณ„์ •์€ ์ž์‹ ์ด ์ˆ˜ํ–‰ํ•˜๋Š” ์—ญํ• (Role)์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ํ‚ค๋ฅผ ํŠธ๋žœ์žญ์…˜ ์„œ๋ช…์— ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

info

Klaytn ํ‚ค ํƒ€์ž…(keyType)์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋‹ค์Œ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

์—ญํ• ์€ ํฌ๊ฒŒ ์ผ๋ฐ˜ ํŠธ๋žœ์žญ์…˜ ์ „์†ก(KLAY ์ „์†ก, ์ปจํŠธ๋ž™ํŠธ ๋ฐฐํฌ, ์ปจํŠธ๋ž™ํŠธ ์‹คํ–‰ ๋“ฑ), ๊ณ„์ • ์—…๋ฐ์ดํŠธ, ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ์˜ 3๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜ API ํ˜ธ์ถœ ์˜ˆ์‹œ๋Š” ์ผ๋ฐ˜ ํŠธ๋žœ์žญ์…˜ ์ „์†ก์šฉ์œผ๋กœ AccountKeyPublic(keyType:2) ํ‚ค, ๊ณ„์ • ์—…๋ฐ์ดํŠธ์šฉ์œผ๋กœ AccountKeyFail(keyType:3) ํ‚ค, ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ์šฉ์œผ๋กœ AccountKeyWeightedMultiSig(keyType:4) ํ‚ค๋ฅผ ๊ฐ€์ง„ ๊ณ„์ •์œผ๋กœ ์—…๋ฐ์ดํŠธ ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ์šฉ ํ‚ค๋Š” ๊ธฐ์ค€์น˜๊ฐ€ 2์ด๊ณ  ํŠธ๋žœ์žญ์…˜ ์„œ๋ช…์šฉ ํ‚ค๊ฐ€ 2๊ฐœ์ด๋ฉฐ ๊ฐ ํ‚ค๋Š” ๊ฐ€์ค‘์น˜ 1์”ฉ์„ ๊ฐ–๋Š” ๋‹ค์ค‘ ์„œ๋ช…์šฉ ํ‚ค์ž…๋‹ˆ๋‹ค. ์ด ๊ณ„์ •์€ ๊ณ„์ • ์—…๋ฐ์ดํŠธ ์—ญํ• ์— AccountKeyFail์„ ์ž…๋ ฅํ–ˆ์œผ๋ฏ€๋กœ ๊ณ„์ •์„ ์—…๋ฐ์ดํŠธํ•˜๋Š” ์—ญํ• ์„ ์ˆ˜ํ–‰ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

info

๊ณ„์ • ํ‚ค๋ฅผ ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค๋กœ ๋ฐ”๊ฟ€ ๋•Œ ํŠน์ • ์—ญํ• ์„ ๋ฐฐ์ œํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, ๋ฐฐ์ œํ•˜๋ ค๋Š” ์—ญํ•  ํ‚ค์—๋Š” keyType=3(AccountKeyFail)์„ ์ž…๋ ฅํ•˜์‹ญ์‹œ์˜ค.

info

๊ณ„์ • ํ‚ค๋ฅผ ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค๋กœ ๋ฐ”๊ฟ€ ๋•Œ ํŠน์ • ์—ญํ• ๋งŒ ์—…๋ฐ์ดํŠธํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, ์—…๋ฐ์ดํŠธํ•˜๊ณ  ์‹ถ์ง€ ์•Š์€ ์—ญํ•  ํ‚ค์—๋Š” keyType=128(AccountKeyNil)์„ ์ž…๋ ฅํ•˜์‹ญ์‹œ์˜ค.

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
// ๊ฐ AccountKey ํƒ€์ž… ๋ณ„ ํŠธ๋žœ์žญ์…˜ ํฌ๋งท์€ ํŽ˜์ด์ง€ ์ƒ๋‹จ์˜ "๊ณ„์ • ํ‚ค๋ฅผ ๋‹ค์ค‘ ์„œ๋ช… ํ‚ค๋กœ ๋ณ€๊ฒฝ: ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋‚ด๋Š” ๊ณ„์ •์ด ํŠธ๋žœ์žญ์…˜ ์ „์†ก ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ๋ถ€๋‹ดํ•˜๊ธฐ" ์ฑ•ํ„ฐ๋ฅผ ์ฐธ๊ณ ํ•˜์‹ญ์‹œ์˜ค.
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 : false์ด๋ฉด ํŠธ๋žœ์žญ์…˜์ด ์ „์†ก๋˜์ง€ ์•Š๊ณ , ์„œ๋ช…๋œ ํŠธ๋žœ์žญ์…˜ RLP์™€ ํŠธ๋žœ์žญ์…˜ ์ •๋ณด๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
  • feePayer : ์‚ฌ์šฉ์ž๊ฐ€ ํŠธ๋žœ์žญ์…˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ๋Œ€๋‚ฉํ•˜๋Š” ๊ณ„์ •์„ ๋ณ„๋„๋กœ ์‚ฌ์šฉํ•  ๋•Œ, ์ด ๊ณ„์ • ์ฃผ์†Œ๋ฅผ ์—ฌ๊ธฐ์— ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค. KAS์—์„œ ๋จผ์ € ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ๋Œ€๋‚ฉํ•ด์ฃผ๋Š” ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด feePayer ํŒŒ๋ผ๋ฏธํ„ฐ ์ž์ฒด๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
  • feeRatio : ํŠธ๋žœ์žญ์…˜ ์ˆ˜์ˆ˜๋ฃŒ ์ „์ฒด์—์„œ feePayer ๊ฐ€ ๋‚ฉ๋ถ€ํ•  ๋น„์œจ(1%~99%)์ž…๋‹ˆ๋‹ค. ๋‚˜๋จธ์ง€ ๋น„์œจ์€ ํŠธ๋žœ์žญ์…˜์„ Klaytn์— ๋ณด๋‚ด๋Š” from ์ด ์ง์ ‘ ๋‚ฉ๋ถ€ํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž ๋Œ€๋‚ฉ ๊ณ„์ •์œผ๋กœ ๋‚ฉ๋ถ€ํ•˜๊ฑฐ๋‚˜ KAS์—์„œ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ๋Œ€๋‚ฉํ•˜๋Š” 2๊ฐ€์ง€ ๋ฐฉ์‹ ๋ชจ๋‘, feeRatio๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

API ์‘๋‹ต

์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๊ณ„์ • ์—…๋ฐ์ดํŠธ ํŠธ๋žœ์žญ์…˜ ์ „์†ก 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 ๋ณ€์ˆ˜๋Š” ํŠธ๋žœ์žญ์…˜ ์ข…๋ฅ˜๋ฅผ ๊ตฌ๋ณ„ํ•˜๋Š” ๊ฐ’์ž…๋‹ˆ๋‹ค. ํŠธ๋žœ์žญ์…˜์˜ ์ข…๋ฅ˜์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋‹ค์Œ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

์ด API์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋‹ค์Œ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.
์ด ๋ฌธ์„œ ํ˜น์€ KAS์— ๊ด€ํ•œ ๋ฌธ์˜๋Š” ๊ฐœ๋ฐœ์ž ํฌ๋Ÿผ์„ ๋ฐฉ๋ฌธํ•ด ๋„์›€ ๋ฐ›์œผ์‹ญ์‹œ์˜ค.

๊ณ„์ • ํ‚ค๋ฅผ ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค๋กœ ๋ณ€๊ฒฝ 2

์—ฌ๊ธฐ์„œ ์†Œ๊ฐœํ•˜๋Š” ๋‚ด์šฉ์€ KAS๊ฐ€ ํŠธ๋žœ์žญ์…˜ ์ „์†ก ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ๋ถ€๋‹ดํ•  ๋•Œ ๊ณ„์ • ํ‚ค๋ฅผ ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. Klaytn ๊ณ„์ • ํ‚ค๋ฅผ ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค๋กœ ๋ฐ”๊พธ๋Š” ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค. ๊ณ„์ • ํ‚ค๋ฅผ ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค ์™ธ์— ๋‹ค๋ฅธ ํ‚ค๋กœ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์œผ๋ฉฐ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๊ณ„์ •์ด ์ด ํŠธ๋žœ์žญ์…˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ๋Œ€๋‚ฉํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Klaytn ๊ณ„์ • ํ‚ค ์ข…๋ฅ˜๋Š” ๋‹ค์Œ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

info

Klaytn ๊ณ„์ •์„ ์—ญํ•  ๊ธฐ๋ฐ˜ ๊ณ„์ •์œผ๋กœ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๊ฒƒ์€ ๊ณ„์ • ํ‚ค๋ฅผ AccountKeyRoleBased๋กœ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๊ฒƒ๊ณผ ๋™์ผํ•ฉ๋‹ˆ๋‹ค.

KAS๋กœ ๊ณ„์ • ์—…๋ฐ์ดํŠธ ํŠธ๋žœ์žญ์…˜์„ ์ „์†กํ•˜๋ ค๋ฉด Klaytn Node์— ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋‚ด์•ผ ํ•˜๋ฉฐ, ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋‚ด๋ ค๋ฉด ํŠธ๋žœ์žญ์…˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ง€๋ถˆํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. API๋ฅผ ํ˜ธ์ถœํ•˜๋ ค๋ฉด ๊ณ„์ • ์ €์žฅ์†Œ์— ๊ณ„์ •์„ ์ƒ์„ฑํ•˜๊ณ  ์‚ฌ์šฉํ•  ๊ณ„์ •์„ ์„ ํƒํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ด ์˜ˆ์‹œ๋ฅผ ๋”ฐ๋ผ Klay๋ฅผ ๋ณด๋‚ด๋ฉด, KLAY๋ฅผ ๋ณด๋‚ด๋Š” ๊ณ„์ •(Account)์ด ์•„๋‹ˆ๋ผ ๋‹ค๋ฅธ ๊ณ„์ •(KAS์˜ ๊ธ€๋กœ๋ฒŒ ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๊ณ„์ •)์ด ์ด ํŠธ๋žœ์žญ์…˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ๋Œ€์‹  ๋ถ€๋‹ดํ•ฉ๋‹ˆ๋‹ค. KAS ๊ธ€๋กœ๋ฒŒ ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๊ณ„์ •(KAS GlobalFeePayer)์ด ํŠธ๋žœ์žญ์…˜์„ ์ „์†กํ•˜๋Š” Klaytn ๊ณ„์ •์„ ๋Œ€์‹ ํ•ด ๋ถ€๋‹ดํ•œ ์ˆ˜์ˆ˜๋ฃŒ๋Š” ์ถ”ํ›„ ์—ฌ๋Ÿฌ๋ถ„์˜ KAS ๊ณ„์ •์— ์ฒญ๊ตฌ๋ฉ๋‹ˆ๋‹ค. KAS์—์„œ ์ œ๊ณตํ•˜๋Š” ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๋ฐฉ์‹์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋‹ค์Œ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

info

KAS SDK(caver-js/caver-java extension) ์„ค์น˜, ์‹คํ–‰์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ KAS SDK๋ฅผ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.
๊ณ„์ • ์ €์žฅ์†Œ ์ƒ์„ฑ, ๊ณ„์ • ์ƒ์„ฑ, ๊ณ„์ • ์„ ํƒ์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ Getting Started๋ฅผ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

API ํ˜ธ์ถœ

KAS GlobalFeePayer ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๋ฐฉ์‹ ๊ณ„์ • ์—…๋ฐ์ดํŠธ ํŠธ๋žœ์žญ์…˜ ์ „์†ก API๋ฅผ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค. API ํ˜ธ์ถœ ์‹œ REST API๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜ API ํ˜ธ์ถœ ์˜ˆ์‹œ๋Š”, Klaytn ๊ณ„์ •์„ ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค(AccountKeyRoleBased, KAS์—์„œ๋Š” keyType:5)๋กœ ์—…๋ฐ์ดํŠธํ•ฉ๋‹ˆ๋‹ค. ์–ด๋–ค Klaytn ๊ณ„์ •์ด ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค๋ฅผ ๊ฐ€์ง€๋ฉด ์ด ๊ณ„์ •์€ ์ž์‹ ์ด ์ˆ˜ํ–‰ํ•˜๋Š” ์—ญํ• (Role)์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ํ‚ค๋ฅผ ํŠธ๋žœ์žญ์…˜ ์„œ๋ช…์— ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

info

Klaytn ํ‚ค ํƒ€์ž…(keyType)์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋‹ค์Œ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

์—ญํ• ์€ ํฌ๊ฒŒ ์ผ๋ฐ˜ ํŠธ๋žœ์žญ์…˜ ์ „์†ก(KLAY ์ „์†ก, ์ปจํŠธ๋ž™ํŠธ ๋ฐฐํฌ, ์ปจํŠธ๋ž™ํŠธ ์‹คํ–‰ ๋“ฑ), ๊ณ„์ • ์—…๋ฐ์ดํŠธ, ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ์˜ 3๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜ API ํ˜ธ์ถœ ์˜ˆ์‹œ๋Š” ์ผ๋ฐ˜ ํŠธ๋žœ์žญ์…˜ ์ „์†ก์šฉ์œผ๋กœ AccountKeyPublic(keyType:2) ํ‚ค, ๊ณ„์ • ์—…๋ฐ์ดํŠธ์šฉ์œผ๋กœ AccountKeyFail(keyType:3) ํ‚ค, ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ์šฉ์œผ๋กœ AccountKeyWeightedMultiSig(keyType:4) ํ‚ค๋ฅผ ๊ฐ€์ง„ ๊ณ„์ •์œผ๋กœ ์—…๋ฐ์ดํŠธ ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ์šฉ ํ‚ค๋Š” ๊ธฐ์ค€์น˜๊ฐ€ 2์ด๊ณ  ํŠธ๋žœ์žญ์…˜ ์„œ๋ช…์šฉ ํ‚ค๊ฐ€ 2๊ฐœ์ด๋ฉฐ ๊ฐ ํ‚ค๋Š” ๊ฐ€์ค‘์น˜ 1์”ฉ์„ ๊ฐ–๋Š” ๋‹ค์ค‘ ์„œ๋ช…์šฉ ํ‚ค์ž…๋‹ˆ๋‹ค. ์ด ๊ณ„์ •์€ ๊ณ„์ • ์—…๋ฐ์ดํŠธ ์—ญํ• ์— AccountKeyFail์„ ์ž…๋ ฅํ–ˆ์œผ๋ฏ€๋กœ ๊ณ„์ •์„ ์—…๋ฐ์ดํŠธํ•˜๋Š” ์—ญํ• ์„ ์ˆ˜ํ–‰ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

info

๊ณ„์ • ํ‚ค๋ฅผ ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค๋กœ ๋ฐ”๊ฟ€ ๋•Œ ํŠน์ • ์—ญํ• ์„ ๋ฐฐ์ œํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, ๋ฐฐ์ œํ•˜๋ ค๋Š” ์—ญํ•  ํ‚ค์—๋Š” keyType=3(AccountKeyFail)์„ ์ž…๋ ฅํ•˜์‹ญ์‹œ์˜ค.

info

๊ณ„์ • ํ‚ค๋ฅผ ์—ญํ•  ๊ธฐ๋ฐ˜ ํ‚ค๋กœ ๋ฐ”๊ฟ€ ๋•Œ ํŠน์ • ์—ญํ• ๋งŒ ์—…๋ฐ์ดํŠธํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, ์—…๋ฐ์ดํŠธํ•˜๊ณ  ์‹ถ์ง€ ์•Š์€ ์—ญํ•  ํ‚ค์—๋Š” keyType=128(AccountKeyNil)์„ ์ž…๋ ฅํ•˜์‹ญ์‹œ์˜ค.

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
// ๊ฐ AccountKey ํƒ€์ž… ๋ณ„ ํŠธ๋žœ์žญ์…˜ ํฌ๋งท์€ ํŽ˜์ด์ง€ ์ƒ๋‹จ์˜ "๊ณ„์ • ํ‚ค๋ฅผ ๋‹ค์ค‘ ์„œ๋ช… ํ‚ค๋กœ ๋ณ€๊ฒฝ: ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋‚ด๋Š” ๊ณ„์ •์ด ํŠธ๋žœ์žญ์…˜ ์ „์†ก ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ๋ถ€๋‹ดํ•˜๊ธฐ" ์ฑ•ํ„ฐ๋ฅผ ์ฐธ๊ณ ํ•˜์‹ญ์‹œ์˜ค.
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 : false์ด๋ฉด ํŠธ๋žœ์žญ์…˜์ด ์ „์†ก๋˜์ง€ ์•Š๊ณ , ์„œ๋ช…๋œ ํŠธ๋žœ์žญ์…˜ RLP์™€ ํŠธ๋žœ์žญ์…˜ ์ •๋ณด๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
  • feeRatio : ํŠธ๋žœ์žญ์…˜ ์ˆ˜์ˆ˜๋ฃŒ ์ „์ฒด์—์„œ feePayer ๊ฐ€ ๋‚ฉ๋ถ€ํ•  ๋น„์œจ(1%~99%)์ž…๋‹ˆ๋‹ค. ๋‚˜๋จธ์ง€ ๋น„์œจ์€ ํŠธ๋žœ์žญ์…˜์„ Klaytn์— ๋ณด๋‚ด๋Š” from ์ด ์ง์ ‘ ๋‚ฉ๋ถ€ํ•ฉ๋‹ˆ๋‹ค.
    • ์‚ฌ์šฉ์ž ๋Œ€๋‚ฉ ๊ณ„์ •์œผ๋กœ ๋‚ฉ๋ถ€ํ•˜๊ฑฐ๋‚˜ KAS์—์„œ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ๋Œ€๋‚ฉํ•˜๋Š” 2๊ฐ€์ง€ ๋ฐฉ์‹ ๋ชจ๋‘, feeRatio๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

API ์‘๋‹ต

KAS GlobalFeePayer ์ˆ˜์ˆ˜๋ฃŒ ๋Œ€๋‚ฉ ๊ณ„์ • ์—…๋ฐ์ดํŠธ ํŠธ๋žœ์žญ์…˜ ์ „์†ก 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 ๋ณ€์ˆ˜๋Š” ํŠธ๋žœ์žญ์…˜ ์ข…๋ฅ˜๋ฅผ ๊ตฌ๋ณ„ํ•˜๋Š” ๊ฐ’์ž…๋‹ˆ๋‹ค. ํŠธ๋žœ์žญ์…˜์˜ ์ข…๋ฅ˜์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋‹ค์Œ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

์ด API์— ๊ด€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋‹ค์Œ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.
์ด ๋ฌธ์„œ ํ˜น์€ KAS์— ๊ด€ํ•œ ๋ฌธ์˜๋Š” ๊ฐœ๋ฐœ์ž ํฌ๋Ÿผ์„ ๋ฐฉ๋ฌธํ•ด ๋„์›€ ๋ฐ›์œผ์‹ญ์‹œ์˜ค.