klay_getAccountKey

Returns the account key of the Externally Owned Account (EOA) of a given address.

📘

Supported on Klaytn (mainnet) only.

Parameters

Request

TypeDescription
20-byte DATAAddress
QUANTITY | TAG | HASHInteger or hexadecimal block number, or the string "earliest", "latest" or "pending" as in the default block parameter, or block hash.

NOTE: In versions earlier than Klaytn v1.7.0, only integer block number, the string "earliest" and "latest" are available.

Result

TypeDescription
AccountKeyThe account key consist of public key(s) and a key type.

API Endpoint

The format of a Klaytn API endpoint is
https://open-platform.nodereal.io/{{apiKey}}/klaytn/

Here is an example:
https://open-platform.nodereal.io/4c0a1c23661a4e26bcbcwed461e34ea9/klaytn/

Example

// Request (AccountKey type: AccountKeyPublic)
curl https://open-platform.nodereal.io/{{apiKey}}/klaytn/ \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"klay_getAccountKey","params":["0x3111a0577f322e8fb54f78d9982a26ae7ca0f722", "latest"],"id":1}'

// Result
{
  "jsonrpc": "2.0",
  "id":1,
  "result": {
    key: {
      x: "0x230037a99462acd829f317d0ce5c8e2321ac2951de1c1b1a18f9af5cff66f0d7",
      y: "0x18a7fb1b9012d2ac87bc291cbf1b3b2339356f1ce7669ae68405389be7f8b3b6"
    },
    keyType: 2
  }
}
// Request (AccountKey type: AccountKeyRoleBased)
curl https://open-platform.nodereal.io/{{apiKey}}/klaytn/ \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"klay_getAccountKey","params":["0x68756d616e616161000000000000000000000000", "latest"],"id":1}'

// Result (AccountKeyRoleBased has nested key structure)
{
  "jsonrpc": "2.0",
  "id":1,
  "result": {
    key: [{
      key: {
        x: "0x819659d4f08e08d4bd97c6ce5ed2c2eb914201a5b3731eb9d208128df24b97dd",
        y: "0x1824267ab9e55f5a3fb1030f0299fa73fc0037305d5b1d90100e2131af41c010"
      },
      keyType: 2
    }, {
      key: {
        x: "0x73363604ca8776a2883b02046361b7eb6bd11f4fc10700ee51c525bcded134c1",
        y: "0xfc3e3cb3f4f5b709df5a2075107bc73c8618440c08456bafc44ee6f27f9e6326"
      },
      keyType: 2
    }, {
      key: {
        x: "0x95c920eb2571dff37baecdbbee32897e6e448c6725c5ab73569cc6f659684307",
        y: "0xef7839023c48acf710ad322356c12b7c5b7f475515ba7d5834f41a993f42b8f9"
      },
      keyType: 2
    }],
    keyType: 5
  }
}
// Request (AccountKey type: AccountKeyLegacy)
curl https://open-platform.nodereal.io/{{apiKey}}/klaytn/ \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"klay_getAccountKey","params":["0x44711E89b0c23845b5B2ed9D3716BA42b8a3e075", "latest"],"id":1}'

// Result
{
  "jsonrpc": "2.0",
  "id":1,
  "result": {
    key: {},
    keyType: 1
  }
}