# Klaytn

## **getKalytnSignedTransaction**

The D'CENT Android SDK provides functions for signing transaction of coins.

**This function for :**

* `.KLAYTN` - klaytn (KLAY)
* `.KLAYTN_TESTNET` - kalytn baobab (KLAYt)

### **Parameters**

* coinType: klaytn networks coin type
* kalytnTransaction: (KlaytnTransation)klaytn transaction parameter

#### **class KlaytnTransaction**

<table><thead><tr><th width="161.33333333333331">Name</th><th width="120">Type</th><th>Description</th></tr></thead><tbody><tr><td>addressPath</td><td><code>String</code></td><td>sign key path for klaytn transaction</td></tr><tr><td>nonce</td><td><code>String</code></td><td>account nonce for klaytn transaction</td></tr><tr><td>to</td><td><code>String</code></td><td>recipient's address of klaytn transaction</td></tr><tr><td>amount</td><td><code>String</code></td><td>amount of ether to be sent. ( wei unit value )</td></tr><tr><td>gasLimit</td><td><code>String</code></td><td>gas limit value of klaytn transaction</td></tr><tr><td>gasPrice</td><td><code>String</code></td><td>gas price for klaytn transaction</td></tr><tr><td>data</td><td><code>String</code></td><td>transaction data of klaytn transaction</td></tr><tr><td>chainId</td><td><code>UInt32</code></td><td>chain id</td></tr><tr><td>from</td><td><code>String</code></td><td>(optional) Signer's Address of klaytn transaction</td></tr><tr><td>tx_type</td><td><code>UInt8</code></td><td>(optional) Type of klaytn transaction<br>The default value is <code>KlaytnType.LEGACY.rawValue</code></td></tr><tr><td>fee_ratio</td><td><code>UInt32</code></td><td>(optional)Fee Ratio of klaytn transaction</td></tr></tbody></table>

**enum KlaytnType**

Defines Transaction type of Klaytn (refer to [klaytn doc](https://docs.klaytn.foundation/content/dapp/json-rpc/api-references/klay/transaction/transaction-type-support))

* `LEGACY`
* `VALUE_TRANSFER`
* `FEE_DELEGATED_VALUE_TRANSFER`
* `FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO`
* `VALUE_TRANSFER_MEMO`
* `FEE_DELEGATED_VALUE_TRANSFER_MEMO`
* `FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO`
* `SMART_CONTRACT_DEPLOY`
* `FEE_DELEGATED_SMART_CONTRACT_DEPLOY`
* `FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO`
* `SMART_CONTRACT_EXECUTION`
* `FEE_DELEGATED_SMART_CONTRACT_EXECUTION`
* `FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO`
* `CANCEL`
* `FEE_DELEGATED_CANCEL`
* `FEE_DELEGATED_CANCEL_WITH_RATIO`
* `FEE_PAYER`

### **Returns**

* result: (Bool) `true` if successful, `false` if error occurred
* txData: signed transaction

**Example**

```swift
let klaytnTransaction : KlaytnTransaction = KlaytnTransaction(addressPath: "0", nonce: "", to: "", amount: "", gasLimit: "", gasPrice: "", data: "", chainId: 0)
  
// test data (legacy)
klaytnTransaction.addressPath = "m/44'/8217'/0'/0/0"
klaytnTransaction.nonce = "8"
klaytnTransaction.to = "0xe5c23dAa6480e45141647E5AeB321832150a28D4"
klaytnTransaction.amount = "60000000000000000"
klaytnTransaction.gasLimit = "25000"
klaytnTransaction.gasPrice = "25000000000"
klaytnTransaction.data = ""
klaytnTransaction.chainId = "1001"
  
DcentMgr.getKlaytnSignedTransaction(coinType:.KLAYTN, klaytnTransaction:klaytnTransaction){ (result, txData) in
    print("Klaytn Transaction closure")
    if result == false {
        print("FAIL !!!")
    }else{
        print(txData)
    }
}
```

## **getKlaytnBasedTokenTransaction**

**This Function for:**

* `.KLAYTN_ERC20` - klaytn erc20 token (krc20)
* `.KRC20_TESTNET` - kalytn testnet erc20 token

### **Parameters**

* coinType: ethereum networks coin type
* tokenTransaction: (KlaytnTokenTransation)klaytn token transaction parameter

#### class KlaytnTokenTransaction

<table><thead><tr><th width="157.33333333333331">Name</th><th width="139">Type</th><th>Description</th></tr></thead><tbody><tr><td>addressPath</td><td><code>String</code></td><td>sign key path for klaytn transaction</td></tr><tr><td>nonce</td><td><code>String</code></td><td>account nonce for klaytn transaction</td></tr><tr><td>to</td><td><code>String</code></td><td>recipient's address of klaytn transaction</td></tr><tr><td>amount</td><td><code>String</code></td><td>amount of ether to be sent. ( wei unit value )</td></tr><tr><td>gasLimit</td><td><code>String</code></td><td>gas limit value of klaytn transaction</td></tr><tr><td>gasPrice</td><td><code>String</code></td><td>gas price for klaytn transaction</td></tr><tr><td>data</td><td><code>String</code></td><td>transaction data of klaytn transaction</td></tr><tr><td>chainId</td><td><code>UInt32</code></td><td>chain id</td></tr><tr><td>tokenName</td><td><code>String</code></td><td>token name of contract for <code>KLAYTN_ERC20</code> transaction</td></tr><tr><td>decimals</td><td><code>UInt32</code></td><td>decimals of contract for <code>KLAYTN_ERC20</code> transaction</td></tr><tr><td>tokenSymbol</td><td><code>String</code></td><td>symbol of contract for <code>KLAYTN_ERC20</code> transaction</td></tr><tr><td>from</td><td><code>String</code></td><td>(optional) Signer's Address of klaytn transaction</td></tr><tr><td>tx_type</td><td><code>UInt8</code></td><td>(optional) Type of klaytn transaction<br>The default value is <code>KlaytnType.LEGACY.rawValue</code></td></tr><tr><td>fee_ratio</td><td><code>UInt32</code></td><td>(optional)Fee Ratio of klaytn transaction</td></tr></tbody></table>

### **Returns**

* result: (Bool) `true` if successful, `false` if error occurred
* txData: signed transaction

**Example**

```swift
let krc20Transaction : KlaytnTokenTransaction = KlaytnTokenTransaction(addressPath: "", nonce: "", to: "", amount: "", gasLimit: "", gasPrice: "", data: "", chainId: 0, tokenName: "", decimals: 0, tokenSymbol: "")
  
// test data
krc20Transaction.addressPath = "m/44'/8217'/0'/0/0"
krc20Transaction.nonce = "6"
krc20Transaction.to = "0x92c1b39556d5322dac96e9e13d35a146297fcf43"
krc20Transaction.amount = "100000000"
krc20Transaction.gasLimit = "100000"
krc20Transaction.gasPrice = "25000000000"
krc20Transaction.data = "0xa9059cbb000000000000000000000000732E035fBdb9E5AB5Ef80c08f6aA081d029984dc"
krc20Transaction.chainId = "1001"
krc20Transaction.tx_type = KlaytnType.FEE_DELEGATED_SMART_CONTRACT_EXECUTION.rawValue
krc20Transaction.fromAddr = "0x689dfa2C77335722f333EeA102ba8A5E13d2AD1a"
krc20Transaction.fee_ratio = 0
krc20Transaction.tokenName = "BAOBABTOKEN"
krc20Transaction.decimals = 8
krc20Transaction.tokenSymbol = "BAO"  

DcentMgr.getKlaytnBasedTokenTransaction(coinType: .KLAYTN_ERC20, tokenTransaction: krc20Transaction){ (result, txData) in
    print("Klaytn token Transaction closure")
    if result == false {
        print("FAIL !!!")
    }else{
        print(txData)
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev-docs.dcentwallet.com/dcent-biometric-wallet-for-mobile/dcent-biometric-sdk-ios/klaytn.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
