This page introduces how to send KLAY from your Klaytn account to other Klaytn account 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.
KLAY is the cryptocurrency of Klaytn. For details about KLAY, please visit here.
Send KLAY: Direct Payment of Transaction Fee
The KLAY transmission API sends a transaction for sending KLAY to another account.
To send Klay, a user must send a transaction to the Klaytn Node and pay the transaction fee. In this example, the account who sends this transaction must directly pay the transaction fee for sending KLAY.
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 KLAY transmission API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.
The API response value is as follows if the KLAY transmission transmit field is pending. Moreover, the KLAY transmission transaction can be pending if signatures are not obtained as required when sending KLAY to a Multiple Signing Account.
// KLAY transmission transaction, which is in pending status, is received as the API response value.{"from": "0x6b0861be172884d6bcec75558b617287404d7073","gasLimit": 1000000,"gasPrice": "0x5d21dba00","input": "0x6d656d6f","nonce": 1,"status": "Pending","to": "0x2f87ba64de5526f7880f21481effbf950f70005c","transactionId": "0x7ee5d33b931e1c172dee21027aeeca31c33ddd44efd02cd3fd4fdfa0a86f888e","typeInt": 16,"value": "0x100"}
transactionId: Transaction ID. This transaction requires multiple signatures.
“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 KLAY: Transaction Fee Delegation by User
The KLAY transmission API sends a transaction for sending KLAY to another account. If you send this transaction with fee-delegation, a fee payer account will pay the transaction fee instead of the transaction sender account.
To send Klay, a user must send a transaction to the 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
Call the fee delegation KLAY transmission API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.
FDUserValueTransferTransactionRequest request =newFDUserValueTransferTransactionRequest();request.setFrom("0x81bA6c299350719B18dFAEC38ba566fBd5Cd7202");request.setTo("0x76c6b1f34562ed7a843786e1d7f57d0d7948a6f1");request.setFeePayer("0x31d845Ac80A0B2a38f6267CabcF34F8fA9DcD2B7");request.setValue("0x1");request.setSubmit(true);FDTransactionResult result =caver.kas.wallet.requestFDValueTransferPaidByUser(request);System.out.println(result);
from: The EOA of a Klaytn account to send the KLAY. This account sends KLAY to “to” account and it also sends this transaction directly.
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 fee delegation KLAY transmission API.
The API response value is as follows if the KLAY transmission transaction is in pending. For example, the KLAY transmission transaction is pending if signatures are not obtained as required when a Multiple Signing Account sends KLAY.
// KLAY transmission transaction, which is in pending status, is received as the API response value.{"feePayer": "0x6a7a7f60346852d23be184aa948fd7c5053c2096","from": "0xe300034949f97251e3c5cf2c9fb5a159f713cae2","gasLimit": 1000000,"gasPrice": "0x5d21dba00","input": "0x6d656d6f","nonce": 1,"status": "Pending","to": "0x2f87ba64de5526f7880f21481effbf950f70005c","transactionId": "0x036de62cde59113716ee3c8d453cf8cc0e2aac0b119d00c0290c1aacb5fe3847","typeInt": 17,"value": "0x12"}
transactionId: Transaction ID. This transaction requires multiple signatures.
“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 KLAY: Transaction Fee Delegation by KAS
The KLAY transmission API sends a transaction for sending KLAY to another account. If you send this transaction with fee-delegation, a fee payer account will pay the transaction fee instead of the transaction sender account.
To send Klay, a user must send a transaction to the 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
Call the KAS GlobalFeePayer fee delegation KLAY transmission API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.
from: The EOA of a Klaytn account to send the KLAY. This account sends KLAY to “to” account and it also sends this transaction directly.
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 KAS GlobalFeePayer fee delegation KLAY transmission API.
FDUserValueTransferTransactionRequest request =newFDUserValueTransferTransactionRequest();request.setFrom("0x81bA6c299350719B18dFAEC38ba566fBd5Cd7202");request.setTo("0x76c6b1f34562ed7a843786e1d7f57d0d7948a6f1");request.setValue("0x1");request.setSubmit(true);FDTransactionResult result =kas.getWallet().requestFDValueTransferPaidByGlobalFeePayer(request);System.out.println(result);
The API response value is as follows if the KLAY transmission transaction is in pending. For example, the KLAY transmission transaction is pending if signatures are not obtained as required when a Multiple Signing Account sends KLAY.
// KLAY transmission transaction, which is in pending status, is received as the API response value.{"feePayer": "0x85b98485444c89880cd9c48807cef727c296f2da","from": "0xe300034949f97251e3c5cf2c9fb5a159f713cae2","gasLimit": 1000000,"gasPrice": "0x5d21dba00","input": "0x6d656d6f","nonce": 1,"status": "Pending","to": "0x2f87ba64de5526f7880f21481effbf950f70005c","transactionId": "0x036de62cde59113716ee3c8d453cf8cc0e2aac0b119d00c0290c1aacb5fe3847","typeInt": 17,"value": "0x12"}