Send Other Transactions

This page introduces how to send legacy transaction to Klaytn or retrieve transaction information 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 Legacy Transaction

In Klaytn, a legacy account has a AccountKeyLegacy which is its public key and private key are bounded to each other because the public key was derived from the private key. This account can only “send KLAY, deploy, and execute smart contracts” (legacy transactions). For more details, refer to Legacy Transaction.

In KAS, the first Klaytn account will be created as a legacy account by default. To send multisig, data anchoring, and other transactions, the legacy account must be Updated to Another Account.

To send this transaction via KAS, the user must send the transaction using KAS to Klaytn Node and pay the transaction fee for this. To call the API, he/she must first create an Account Pool and account, and then select an account to use.

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

Call the legacy transaction transmission API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this. The API Request/Response example below introduces how to send KLAY to another Klaytn account by transmitting a legacy transaction to Klaytn.

curl --location --request POST "https://wallet-api.klaytnapi.com/v2/tx/legacy" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}"
--data-raw "{
  "from": "",
  "value": "0x121111111111111111",
  "to": "0x5bb85d4032354E88020595AFAFC081C24098202e",
  "nonce": 0,
  "gas": 1000000,
  "submit": true
}"

API Response

Here is a response of the legacy transaction transmission API.

{
"from": "0x85b98485444c89880cd9c48807cef727c296f2da",
"gas": 1000000,
"gasPrice": "0x5d21dba00",
"input": "0x",
"nonce": 0,
"rlp": "0xf870808505d21dba00830f424094a311e7022a4db250689c89d99848f74ea5098f7d89121111111111111111808207f5a03e7173bf7a303b4e1bb6f8723b494bcaa196cf7b9d7af18a22ceda7f2e9c9226a057bf51a5f52d900d58470f5e28f25881eb6d3837502ba0bab13f022398ddbc26",
"signatures": [
{}
],
"status": "Submitted",
"to": "0xa311e7022a4db250689c89d99848f74ea5098f7d",
"transactionHash": "0x433d70e6bdbce725ac9472e9fe1242fa0e5bdcd1b60fa21b3dcadf858055b47b",
"typeInt": 0,
"value": "0x121111111111111111"
}

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

Get Transaction Execution Result by Transaction Hash

Enter transaction hash value and search the transaction execution result. status field of response indicates if the transaction execution is successful.

To call the API, he/she must first create an Account Pool and account, and then select an account to use.

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

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

curl --location --request GET "https://wallet-api.klaytnapi.com/v2/tx/0x62cbe2b959dd80b2dae88ccac3caba51c056989d2cb00bf7b4136c4945cc4644" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
  • 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 a response of the transaction search API.

{
  "blockHash": "0x421648a9920d4f97e60dc1d93c62e2b0c2f3a8df5ddb79252ce693974ef7806c",
  "blockNumber": "0xba",
  "contractAddress": null,
  "from": "0x325dbaf78b393dc2115138c86a58f897ed413aff",
  "gas": "0xf4240",
  "gasPrice": "0x5d21dba00",
  "gasUsed": "0x5398",
  "hash": "0x62cbe2b959dd80b2dae88ccac3caba51c056989d2cb00bf7b4136c4945cc4644",
  "input": "0x6d656d6f",
  "logs": [],
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "nonce": "0x1",
  "senderTxHash": "0x62cbe2b959dd80b2dae88ccac3caba51c056989d2cb00bf7b4136c4945cc4644",
  "signatures": [
    {
      "R": "0xf3d42d9f0d82f15a2acd18a5fbde0b1aff26936b89fec5151da59bdad4c4ddef",
      "S": "0x69a8b9319769c5dacffad42232d4d053d11722832169d71bca3f28b211f5f23d",
      "V": "0x7f6"
    }
  ],
  "status": "Committed",
  "to": "0x2f87ba64de5526f7880f21481effbf950f70005c",
  "transactionHash": "0x62cbe2b959dd80b2dae88ccac3caba51c056989d2cb00bf7b4136c4945cc4644",
  "transactionIndex": "0x0",
  "type": "TxTypeValueTransferMemo",
  "typeInt": 16,
  "value": "0x100"
}

“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