Send RLP-encoded Transaction

This page introduces how to send a transaction formatted in RLP-encoded string to Klaytn 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 Transaction Using RLP String: Direct Payment of Transaction Fee

The RLP transaction transmission API sends transactions to Klaytn using RLP-encoded transaction strings. All transactions of Klaytn can be represented by strings encoded in the RLP. Klaytn uses the transaction signature RLP (SigRLP) and transaction hash RLP (TxHashRLP). For details about Klaytn transactions, please visit here.

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

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 transaction signature RLP or transaction hash RLP, and then call the RLP 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/rlp" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
--header "Content-Type: application/json" \
--data-raw "{
  "rlp": "0x10f886018505d21dba00830f4240942f...",
  "submit": true
}"
  • 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 RLP transaction transmission API.

{
  "from": "0x325dbaf78b393dc2115138c86a58f897ed413aff",
  "gasLimit": 1000000,
  "gasPrice": "0x5d21dba00",
  "input": "0x6d656d6f",
  "nonce": 1,
  "rlp": "0x10f886018505d21dba00830f4240942f87ba64de5526f7880f21481effbf950f70005c82010094325dbaf78b393dc2115138c86a58f897ed413aff846d656d6ff847f8458207f6a0f3d42d9f0d82f15a2acd18a5fbde0b1aff26936b89fec5151da59bdad4c4ddefa069a8b9319769c5dacffad42232d4d053d11722832169d71bca3f28b211f5f23d",
  "signatures": [
    {
      "R": "0xf3d42d9f0d82f15a2acd18a5fbde0b1aff26936b89fec5151da59bdad4c4ddef",
      "S": "0x69a8b9319769c5dacffad42232d4d053d11722832169d71bca3f28b211f5f23d",
      "V": "0x7f6"
    }
  ],
  "status": "Submitted",
  "to": "0x2f87ba64de5526f7880f21481effbf950f70005c",
  "transactionHash": "0x62cbe2b959dd80b2dae88ccac3caba51c056989d2cb00bf7b4136c4945cc4644",
  "typeInt": 16,
  "value": "0x100"
}

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

Send Transaction Using RLP String: Transaction Fee Delegation by User

The RLP transaction transmission API sends transactions to Klaytn using RLP-encoded transaction strings. All transactions of Klaytn can be represented by strings encoded in the RLP. Klaytn uses the transaction signature RLP (SigRLP) and transaction hash RLP (TxHashRLP). For details about Klaytn transactions, please visit here.

To send the RLP transaction, the 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.

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

Enter the transaction signature RLP or transaction hash RLP, and then call the RLP 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/rlp" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
--header "Content-Type: application/json" \
--data-raw "{
  "rlp": "0x49f8c8048505d21dba00830f4240...",
  "feePayer": "0x85B98485444c89880cD9C48807CEF727C296F2da",
  "feeRatio": 10,
  "submit": true
}"
  • 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 RLP transaction transmission with fee-delegation API.

{
  "feePayer": "0xe8ab1729ab614551021cf5cc22c0e037f5a82930",
  "from": "0x9c56b45b7443bc73f47234199982481c64807f78",
  "gasLimit": 1000000,
  "gasPrice": "0x5d21dba00",
  "input": "0x",
  "nonce": 4,
  "rlp": "0x49f8c8048505d21dba00830f4240949c56b45b7443bc73f47234199982481c64807f7880f847f8458207f5a0dd824552d22d8bbb55fa36c0717d1f69305fe26c483d161f30cec3d9fd9aad1da0708b3c3a3b0030ad281ae414ec73f1c05d5095043f13e8a53b396db48c98cd6594e8ab1729ab614551021cf5cc22c0e037f5a82930f847f8458207f6a0e23bcc4cf32afbc3c3b362bd8c774cd33d5d3cba7eb4dc45b25dde28543bfd59a061a52ef000023d9ba61ef9d17546e4d2d3f9bbdf893c5192add8be24a07182a2",
  "signatures": [
    {
      "R": "0xdd824552d22d8bbb55fa36c0717d1f69305fe26c483d161f30cec3d9fd9aad1d",
      "S": "0x708b3c3a3b0030ad281ae414ec73f1c05d5095043f13e8a53b396db48c98cd65",
      "V": "0x7f5"
    }
  ],
  "status": "Submitted",
  "transactionHash": "0x366f4f11918ef23314e3d35b1d5bee1067a2d599359fd920f867aa0a3b31d2a2",
  "typeInt": 73
}

“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 Developer forum.

Send Transaction Using RLP String: Transaction Fee Delegation by KAS

The RLP transaction transmission API sends transactions to Klaytn using RLP-encoded transaction strings. All transactions of Klaytn can be represented by strings encoded in the RLP. Klaytn uses the transaction signature RLP (SigRLP) and transaction hash RLP (TxHashRLP). For details about Klaytn transactions, please visit here.

To send the RLP transaction, the 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.

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 transaction signature RLP or transaction hash RLP, and then call the RLP 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/rlp" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
--header "Content-Type: application/json" \
--data-raw "{
  "rlp": "0x49f8c8048505d21dba00830f4240...",
  "feeRatio": 10,
  "submit": true
}"
  • 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 RLP transaction transmission with KAS GlobalFeePayer fee-delegation API.

{
  "feePayer": "0x85b98485444c89880cd9c48807cef727c296f2da",
  "feeRatio": 10,
  "from": "0x9c56b45b7443bc73f47234199982481c64807f78",
  "gasLimit": 1000000,
  "gasPrice": "0x5d21dba00",
  "input": "0x",
  "nonce": 4,
  "rlp": "0x49f8c8048505d21dba00830f4240949c56b45b7443bc73f47234199982481c64807f7880f847f8458207f5a0dd824552d22d8bbb55fa36c0717d1f69305fe26c483d161f30cec3d9fd9aad1da0708b3c3a3b0030ad281ae414ec73f1c05d5095043f13e8a53b396db48c98cd6594e8ab1729ab614551021cf5cc22c0e037f5a82930f847f8458207f6a0e23bcc4cf32afbc3c3b362bd8c774cd33d5d3cba7eb4dc45b25dde28543bfd59a061a52ef000023d9ba61ef9d17546e4d2d3f9bbdf893c5192add8be24a07182a2",
  "signatures": [
    {
      "R": "0xdd824552d22d8bbb55fa36c0717d1f69305fe26c483d161f30cec3d9fd9aad1d",
      "S": "0x708b3c3a3b0030ad281ae414ec73f1c05d5095043f13e8a53b396db48c98cd65",
      "V": "0x7f5"
    }
  ],
  "status": "Submitted",
  "transactionHash": "0x366f4f11918ef23314e3d35b1d5bee1067a2d599359fd920f867aa0a3b31d2a2",
  "typeInt": 73
}

“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 Developer forum.

Last updated