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

NameTypeDescription

addressPath

String

sign key path for klaytn transaction

nonce

String

account nonce for klaytn transaction

to

String

recipient's address of klaytn transaction

amount

String

amount of ether to be sent. ( wei unit value )

gasLimit

String

gas limit value of klaytn transaction

gasPrice

String

gas price for klaytn transaction

data

String

transaction data of klaytn transaction

chainId

UInt32

chain id

from

String

(optional) Signer's Address of klaytn transaction

tx_type

UInt8

(optional) Type of klaytn transaction The default value is KlaytnType.LEGACY.rawValue

fee_ratio

UInt32

(optional)Fee Ratio of klaytn transaction

enum KlaytnType

Defines Transaction type of Klaytn (refer to klaytn doc)

  • 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

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

NameTypeDescription

addressPath

String

sign key path for klaytn transaction

nonce

String

account nonce for klaytn transaction

to

String

recipient's address of klaytn transaction

amount

String

amount of ether to be sent. ( wei unit value )

gasLimit

String

gas limit value of klaytn transaction

gasPrice

String

gas price for klaytn transaction

data

String

transaction data of klaytn transaction

chainId

UInt32

chain id

tokenName

String

token name of contract for KLAYTN_ERC20 transaction

decimals

UInt32

decimals of contract for KLAYTN_ERC20 transaction

tokenSymbol

String

symbol of contract for KLAYTN_ERC20 transaction

from

String

(optional) Signer's Address of klaytn transaction

tx_type

UInt8

(optional) Type of klaytn transaction The default value is KlaytnType.LEGACY.rawValue

fee_ratio

UInt32

(optional)Fee Ratio of klaytn transaction

Returns

  • result: (Bool) true if successful, false if error occurred

  • txData: signed transaction

Example

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)
    }
}

Last updated