Data Anchoring

This page introduces how to send transaction that anchors service chain data to Klaytn main chain 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.

Send Data Anchoring Transaction: Direct Payment of Transaction Fee

Send a transaction for anchoring the service chain data to the Klaytn main chain. For details about service chain, please visit here. For details about data anchoring of service chain, please visit here.

To send the anchoring transaction, the user has to send a transaction to Klaytn Node and pay the transaction fee. To call the API, he/she must create an operator, and then select an operator to use. In this example, the sending operator must directly pay the transaction fee for sending the anchoring transaction.

For details about creating and selecting operator, please visit Getting Started. For details about KAS SDK (caver-js/caver-java extensions) installation and execution, please visit KAS SDK.

API Request

Call the data anchoring transaction transmission API You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

curl --location --request POST "https://wallet-api.klaytnapi.com/v2/tx/anchor" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
--header "Content-Type: application/json" \
--data-raw "{
  "from": "0x5bb85d4032354E88020595AFAFC081C24098202e",
  "input": "0x123",
  "nonce": 0,
  "gasLimit": 1000000,
  "submit": true
}"
  • from: The address (EOA) of the operator that was created in KAS Console.

  • submit: If it is false, a transaction is not sent and the RLP of signed transaction and the transaction information are returned.

Data Anchoring Transaction Transmission of Anchor API sends data anchoring transactions to Klaytn with this API.

API Response

Here is a response of the data anchoring transaction transmission API.

{
  "from": "0x325dbaf78b393dc2115138c86a58f897ed413aff",
  "gasLimit": 1000000,
  "gasPrice": "0x5d21dba00",
  "input": "0x",
  "nonce": 0,
  "rlp": "0x48f86a808505d21dba00830f424094325dbaf78b393dc2115138c86a58f897ed413aff80f847f8458207f5a02005933be0d96e6d39762e3b1b5028d98495e4c07bf20d09660883c0a6e64285a036aa5181b89c72aa02921f8907cc6436103392d4b761a37920c1ffd99cba8a3f",
  "signatures": [
    {
      "R": "0x2005933be0d96e6d39762e3b1b5028d98495e4c07bf20d09660883c0a6e64285",
      "S": "0x36aa5181b89c72aa02921f8907cc6436103392d4b761a37920c1ffd99cba8a3f",
      "V": "0x7f5"
    }
  ],
  "status": "Submitted",
  "transactionHash": "0x3a1b7ad3802f901584539a1799f90a137464d2f84de27fc7eb98b96ed5e4fd7c",
  "typeInt": 72
}

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

Send Data Anchoring Transaction: Transaction Fee Delegation by User

Send a transaction for anchoring the service chain data to the Klaytn main chain. For details about service chain, please visit here. For details about data anchoring of service chain, please visit here.

To send the anchoring transaction, the user has to send a transaction to Klaytn Node and pay the transaction fee. To call this API, you first need to create the operator who sends this transaction and the Klaytn account who pays the transaction fee (fee-payer) in Fee Payer Account Pool. In this example, the fee payer account pays the transaction transmission fee, not the operator who sends this transaction. For details about fee-delegation methods that KAS provides for you, please visit here.

For details about creating and selecting operator, please visit 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. For details about KAS SDK (caver-js/caver-java extensions) installation and execution, please visit KAS SDK.

Fee-delegation configuration in KAS Console - Anchor - Operator menu is only applied to Anchor API, not to this API.

API Request

Call the data anchoring transaction transmission with fee delegation API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

curl --location --request POST "https://wallet-api.klaytnapi.com/v2/tx/fd-user/anchor" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
--header "Content-Type: application/json" \
--data-raw "{
  "from": "0x5bb85d4032354E88020595AFAFC081C24098202e",
  "input": "0x123",
  "nonce": 0,
  "gasLimit": 1000000,
  "submit": true,
  "feePayer": "0x85B98485444c89880cD9C48807CEF727C296F2da",
  "feeRatio": 10
}"
  • from: The address of the operator that was created in KAS Console.

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

If the balance of the fee payer is less than the transaction fee, anchoring transaction will not be sent. If you want to guarantee sending the anchoring transaction, please set UseGlobalFeePayer and use Anchor API.

API Response

Here is the response of data anchoring transaction transmission with fee delegation API.

{
  "feePayer": "0x85B98485444c89880cD9C48807CEF727C296F2da",
  "from": "0x5bb85d4032354E88020595AFAFC081C24098202e",
  "gasLimit": 1000000,
  "gasPrice": "0x5d21dba00",
  "input": "0x",
  "nonce": 5,
  "rlp": "0x49f8c8058505d21dba00830f4240949c56b45b7443bc73f47234199982481c64807f7880f847f8458207f5a0aa2ae446f5dd35df839e8ec2005aede91f0b3ea0f1e6889f4294d4760529bfafa07b3efab682bcc86f7050819e12a2b5ea916871d684b9e1c8ca8f49869df4189694e8ab1729ab614551021cf5cc22c0e037f5a82930f847f8458207f6a0aa12d32c96ef21d3b90d1f126a389fa2eb4dc283b18e3a42d41ee1353dc91126a05d7f40f320f4b8388272d9f61ad4a7d194762cbfdcc4d31a51e7c87d72aca591",
  "signatures": [
    {
      "R": "0xaa2ae446f5dd35df839e8ec2005aede91f0b3ea0f1e6889f4294d4760529bfaf",
      "S": "0x7b3efab682bcc86f7050819e12a2b5ea916871d684b9e1c8ca8f49869df41896",
      "V": "0x7f5"
    }
  ],
  "status": "Submitted",
  "transactionHash": "0x341abe135468e12807906ff6c4fde87ebd33cec1fbbd5243e8b980eabad2551d",
  "typeInt": 73
}

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

Send Data Anchoring Transaction: Transaction Fee Delegation by KAS

Send a transaction for anchoring the service chain data to the Klaytn main chain. For details about service chain, please visit here. For details about data anchoring of service chain, please visit here.

To send the anchoring transaction, the user has to send a transaction to Klaytn Node and pay the transaction fee. To call this API, you first need to create a Klaytn account (=operator) who sends this transaction. In this example, the KAS global fee payer account pays the transaction transmission fee, not the operator who sends this transaction. This fee paid by KAS global fee payer instead of the operator 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.

For details about KAS SDK (caver-js/caver-java extensions) installation and execution, please visit KAS SDK. For details about creating and selecting operator, please visit Getting Started.

Fee-delegation configuration in KAS Console - Anchor - Operator menu is only applied to Anchor API, not to this API.

API Request

Call the data anchoring transaction transmission with KAS GlobalFeePayer fee delegation API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

curl --location --request POST "https://wallet-api.klaytnapi.com/v2/tx/fd/anchor" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
--header "Content-Type: application/json" \
--data-raw "{
  "from": "0x5bb85d4032354E88020595AFAFC081C24098202e",
  "input": "0x123",
  "nonce": 0,
  "gasLimit": 1000000,
  "submit": true,
  "feeRatio": 10
}"
  • from: The address of the operator that was created in KAS Console.

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

If the balance of the fee payer is less than the transaction fee, anchoring transaction will not be sent. If you want to guarantee sending the anchoring transaction, please set UseGlobalFeePayer and use Anchor API instead of this API.

API Response

Here is the response of data anchoring transaction transmission with KAS GlobalFeePayer fee delegation API.

{
  "feePayer": "0x85b98485444c89880cd9c48807cef727c296f2da",
  "feeRatio": 10,
  "from": "0x5bb85d4032354E88020595AFAFC081C24098202e",
  "gasLimit": 1000000,
  "gasPrice": "0x5d21dba00",
  "input": "0x",
  "nonce": 5,
  "rlp": "0x49f8c8058505d21dba00830f4240949c56b45b7443bc73f47234199982481c64807f7880f847f8458207f5a0aa2ae446f5dd35df839e8ec2005aede91f0b3ea0f1e6889f4294d4760529bfafa07b3efab682bcc86f7050819e12a2b5ea916871d684b9e1c8ca8f49869df4189694e8ab1729ab614551021cf5cc22c0e037f5a82930f847f8458207f6a0aa12d32c96ef21d3b90d1f126a389fa2eb4dc283b18e3a42d41ee1353dc91126a05d7f40f320f4b8388272d9f61ad4a7d194762cbfdcc4d31a51e7c87d72aca591",
  "signatures": [
    {
      "R": "0xaa2ae446f5dd35df839e8ec2005aede91f0b3ea0f1e6889f4294d4760529bfaf",
      "S": "0x7b3efab682bcc86f7050819e12a2b5ea916871d684b9e1c8ca8f49869df41896",
      "V": "0x7f5"
    }
  ],
  "status": "Submitted",
  "transactionHash": "0x341abe135468e12807906ff6c4fde87ebd33cec1fbbd5243e8b980eabad2551d",
  "typeInt": 73
}

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

Last updated