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.
LegacyTransactionRequest request =newLegacyTransactionRequest();request.setFrom("0x81bA6c299350719B18dFAEC38ba566fBd5Cd7202");request.setTo("0x95E3Fd82eCd2b32Cae8618599971F5F47F4bC110");request.setGas((long)25000);request.setValue("0x1");request.setSubmit(true);TransactionResult result =caver.kas.wallet.requestLegacyTransaction(request);System.out.println(result);
API Response
Here is a response of the legacy transaction transmission API.
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.