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.

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.

info

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.

cURLJavaScriptJava
Copy
Copied
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
}"
Copy
Copied
const tx = {
  from: "0x23a386d059a41512f3aC36952cFc6CC4BAAe4Ed5",
  gas: 100000,
  input: "0x0123",
  submit: true,
};
const result = await caver.kas.wallet.requestChainDataAnchoring(tx);
Copy
Copied
AnchorTransactionRequest request = new AnchorTransactionRequest();
request.setFrom("0x81ba6c299350719b18dfaec38ba566fbd5cd7202");
request.setInput("0x0111");
request.setSubmit(true);

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

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.

cURLJavaScriptJava
Copy
Copied
{
  "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
}
Copy
Copied
TransactionResult {
  from: '0x23a386d059a41512f3ac36952cfc6cc4baae4ed5',
  gas: 100000,
  gasPrice: '0x5d21dba00',
  nonce: 0,
  rlp: '0x48f86c808505d21dba00830186a09423a386d059a41512f3ac36952cfc6cc4baae4ed5820123f847f8458207f5a0527ab840698302389711ebcd18fb631aa99243456b5c39c28e93fc703be96f7aa066632c1cfdd735c8c26468e90f266db29ea9a567b4e1003a418b6bd589c2d82e',
  typeInt: 72,
  input: '0x0123',
  signatures: [
    Signature {
      R: '0x527ab840698302389711ebcd18fb631aa99243456b5c39c28e93fc703be96f7a',
      S: '0x66632c1cfdd735c8c26468e90f266db29ea9a567b4e1003a418b6bd589c2d82e',
      V: '0x7f5'
    }
  ],
  status: 'Submitted',
  transactionHash: '0x6a24db0c181bb9211644f0c566ee3f4f9555be99a197608e8b04962c4b2b62cf'
}
Copy
Copied
class TransactionResult {
    from: 0x81ba6c299350719b18dfaec38ba566fbd5cd7202
    gas: 1000000
    gasPrice: 0x5d21dba00
    input: 0x0111
    nonce: 937
    rlp: 0x48f86e8203a98505d21dba00830186a09481ba6c299350719b18dfaec38ba566fbd5cd7202820111f847f8458207f5a06ff694dd252213c0afbbd3efab36fcc3ffb70266f8f04c3d54644b7197441ad0a035922e305800ed6277876abd30d1705836b2660379dbdbda2b2765e13402b6ed
    signatures: [class Signature {
        R: 0x6ff694dd252213c0afbbd3efab36fcc3ffb70266f8f04c3d54644b7197441ad0
        S: 0x35922e305800ed6277876abd30d1705836b2660379dbdbda2b2765e13402b6ed
        V: 0x7f5
    }]
    status: Submitted
    to: null
    transactionHash: 0x4e48a3188bacf11db84e8e688c5ef3f641ab8b4361c30afb4fae243391e879d2
    typeInt: 72
    value: null
    code: null
    message: null
    transactionId: null
    accountKey: null
}

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

info

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.

info

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.

cURLJavaScriptJava
Copy
Copied
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
}"
Copy
Copied
const tx = {
  from: "0x7A78fe7544dD2a448c6a147a34018B72dDDAC620",
  gas: 100000,
  input: "0x0123",
  feePayer: "0x44Ee3906a7a2007762E9d706dF6E4eF63FA1edA8",
  submit: true,
};
const result = await caver.kas.wallet.requestFDChainDataAnchoringPaidByUser(tx);
Copy
Copied
FDUserAnchorTransactionRequest request = new FDUserAnchorTransactionRequest();
request.setFrom("0x81ba6c299350719b18dfaec38ba566fbd5cd7202");
request.setFeePayer("0x31d845ac80a0b2a38f6267cabcf34f8fa9dcd2b7");
request.setInput("0x123456");
request.setSubmit(true);

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

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.

cURLJavaScriptJava
Copy
Copied
{
  "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
}
Copy
Copied
FDTransactionResult {
  feePayer: '0x44ee3906a7a2007762e9d706df6e4ef63fa1eda8',
  from: '0x7a78fe7544dd2a448c6a147a34018b72dddac620',
  gas: 100000,
  gasPrice: '0x5d21dba00',
  nonce: 0,
  rlp: '0x49f8ca808505d21dba00830186a0947a78fe7544dd2a448c6a147a34018b72dddac620820123f847f8458207f6a0a11c4bf111b967a85f1e999cf73b0c142437f84d7a39cb415d3b8dfe4270169ba0781754eabc446987e1eaef7b93c288c65484a5243d28f24a33ad9d363c62595f9444ee3906a7a2007762e9d706df6e4ef63fa1eda8f847f8458207f5a0ddb5a7914c45c2ef807d116e957e6f9a51aba22a0748ff55a169a52d0b3ba0bda03254495a0bbe8c369d6415a652e056a41f19f5fbb029c767e299e3d316c48245',
  typeInt: 73,
  input: '0x0123',
  signatures: [
    Signature {
      R: '0xa11c4bf111b967a85f1e999cf73b0c142437f84d7a39cb415d3b8dfe4270169b',
      S: '0x781754eabc446987e1eaef7b93c288c65484a5243d28f24a33ad9d363c62595f',
      V: '0x7f6'
    }
  ],
  status: 'Submitted',
  transactionHash: '0x381b129fb29d6024ead5591e444de6b43360a0e9c0dcc0c0f4d4aafdeea3b61d'
}
Copy
Copied
class FDTransactionResult {
    feePayer: 0x31d845ac80a0b2a38f6267cabcf34f8fa9dcd2b7
    from: 0x81ba6c299350719b18dfaec38ba566fbd5cd7202
    gas: 1000000
    gasPrice: 0x5d21dba00
    input: 0x123456
    nonce: 939
    rlp: 0x49f8cd8203ab8505d21dba00830186a09481ba6c299350719b18dfaec38ba566fbd5cd720283123456f847f8458207f5a022c3565808440a30dc84b65a495b7adbeb3a6bd07a2dcb0fb6f1cc21e0cd435ea00623daa288e8ae4ffd7db08e41918720e4e4203345a190a2eb3137b5a96354089431d845ac80a0b2a38f6267cabcf34f8fa9dcd2b7f847f8458207f5a0c077a85668ae954b42bc4d7c223f1f1795dc0e0b96a92208a315725222f833f4a060595d90874b9908084a01c348a648e7a9a5c5d1e75d34563fd72ad00ada367b
    signatures: [class Signature {
        R: 0x22c3565808440a30dc84b65a495b7adbeb3a6bd07a2dcb0fb6f1cc21e0cd435e
        S: 0x623daa288e8ae4ffd7db08e41918720e4e4203345a190a2eb3137b5a9635408
        V: 0x7f5
    }]
    status: Submitted
    to: null
    transactionHash: 0x290855d5b4364089b355c430a521f5d1ab9c3457709894a3ca48d4bb16690cdb
    typeInt: 73
    value: null
    feeRatio: null
    transactionId: null
    accountKey: null
}

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

info

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.

info

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.

cURLJavaScriptJava
Copy
Copied
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
}"
Copy
Copied
const tx = {
  from: "0x6c4C0226d58f0F87411e1Ec085f3629fA156bf06",
  gas: 100000,
  input: "0x0123",
  feeRatio: 99,
  submit: true,
};
const result =
  await caver.kas.wallet.requestFDChainDataAnchoringPaidByGlobalFeePayer(tx);
Copy
Copied
FDAnchorTransactionRequest request = new FDAnchorTransactionRequest();
request.setFrom("0x81ba6c299350719b18dfaec38ba566fbd5cd7202");
request.setInput("0x1111");
request.setSubmit(true);

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

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.

cURLJavaScriptJava
Copy
Copied
{
  "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
}
Copy
Copied
FDTransactionResult {
  feePayer: '0x1b71a63903e35371e2fc41c6012effb99b9a2c0f',
  from: '0x6c4c0226d58f0f87411e1ec085f3629fa156bf06',
  gas: 100000,
  gasPrice: '0x5d21dba00',
  nonce: 1,
  rlp: '0x4af8cb018505d21dba00830186a0946c4c0226d58f0f87411e1ec085f3629fa156bf0682012363f847f8458207f5a064dede6045075a560989ee544dec66be1991ffb0e5b04b5f206951752b77e3f4a01cd8dd04a80617dbb900d79632d491d17bc1d65f427d9c2632d40f7f3e66ac43941b71a63903e35371e2fc41c6012effb99b9a2c0ff847f8458207f6a017cedf4d0478ea30e741d77ec1d1b61e57c553ac880cea0245f74ac653ee01cba049a11270ea7f90836cef28bb073880f7c6d48db52bf6a2b97c17678f8e64e20a',
  typeInt: 74,
  input: '0x0123',
  signatures: [
    Signature {
      R: '0x64dede6045075a560989ee544dec66be1991ffb0e5b04b5f206951752b77e3f4',
      S: '0x1cd8dd04a80617dbb900d79632d491d17bc1d65f427d9c2632d40f7f3e66ac43',
      V: '0x7f5'
    }
  ],
  status: 'Submitted',
  transactionHash: '0xb8005c15187cf9ac3a43a7f6059a49a625da70dbe473afc2d48019927cc29872',
  feeRatio: 99
}
Copy
Copied
class FDTransactionResult {
    feePayer: 0x1b71a63903e35371e2fc41c6012effb99b9a2c0f
    from: 0x81ba6c299350719b18dfaec38ba566fbd5cd7202
    gas: 1000000
    gasPrice: 0x5d21dba00
    input: 0x1111
    nonce: 940
    rlp: 0x49f8cc8203ac8505d21dba00830186a09481ba6c299350719b18dfaec38ba566fbd5cd7202821111f847f8458207f6a01d5ea7a5d33ee8b456b89998afdabec4497c8160091794c37040f120b06b3e2fa02cae2de18c29c8204d8cb36d43631edaf0d2ee4d2e2d919053d98371a9267368941b71a63903e35371e2fc41c6012effb99b9a2c0ff847f8458207f5a0c7d70ab5360ac5af9ea232821a79f2022e95c4d858aaa5fe224efa519bf6211ba05bd484882692b5869fc5d378efd1541d9e333555a0ab15f58d6daa108be8dadd
    signatures: [class Signature {
        R: 0x1d5ea7a5d33ee8b456b89998afdabec4497c8160091794c37040f120b06b3e2f
        S: 0x2cae2de18c29c8204d8cb36d43631edaf0d2ee4d2e2d919053d98371a9267368
        V: 0x7f6
    }]
    status: Submitted
    to: null
    transactionHash: 0x4aebd7100c7f2c648a6a348ba970120f64759613dfbfaa4b25244394367c72e3
    typeInt: 73
    value: null
    feeRatio: null
    transactionId: null
    accountKey: null
}

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developers Forum.