Skip to main content

Ethereum & EVM compatible

getEthereumSignedTransaction

The DCENT iOS SDK provides functions for signing transaction of coins.

This function is for:

  • .ETHEREUM - ethereum (ETH)
  • .ETH_CLASSIC - ethereum classic (ETC)
  • .ETH_KOVAN - ethereum kovan (ETHt)
  • .ETH_ROPSTEN - ethereum ropsten (ETHt)
  • .ETH_GOERLI - ethereum goerli (ETHt)
  • .ETH_RINKEBY - ethereum rinkeby (ETHt)
  • .FLR_COSTON - flare network coston (CFLR)
  • .RSK - rsk smart bitcoin (RBTC)
  • .RSK_TESTNET - rsk smart bitcoin testnet (RBTCt)
  • .XDC - xdc network (XDC)
  • .XDC_APOTHEM - xdc apothem (XDCt)
  • .BSC - binance smart chain (BNB)
  • .BSC_TESTNET - binance smart chain testnet (BNBt)
  • .POLYGON - polygon (MATIC)
  • .POLYGON_TESTNET - polygon testnet (MATICt)
  • .CHAN - other evm networks

Parameters

  • coinType: ethereum networks coin type
  • ethereumTransaction: (EthereumTransaction)ethereum transaction parameter

class EthereumTransaction

NameTypeDescription
addressPathStringsign key path for ethereum transaction
nonceStringaccount nonce for ethereum transaction
toStringrecipient's address of ethereum transaction
amountStringamount of ether to be sent. ( wei unit value )
gasLimitStringgas limit value of ethereum transaction
gasPriceStringgas price for ethereum transaction
dataStringtransaction data of ethereum transaction
chainIdStringchain id
symbolStringsymbol for ethereum transaction
symbol value used for evm chain (.CHAN)
txTypeString(optional)Type of ethereum transaction
maxPriorityFpgString(optional)max_priority_fpg of ethereum transaction
maxFeePerGasString(optional)max_fee_per gas of ethereum transaction
accessListString(optional)access_list of ethereum transaction

Returns

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

Requirements

Example

let ethereumTransaction : EthereumTransaction = EthereumTransaction( addressPath:"", nonce:"", to:"", amount:"", gasLimit:"", gasPrice:"", data:"", chainId:"0" )

// test data
ethereumTransaction.addressPath = "m/44'/60'/0'/0/0"
ethereumTransaction.nonce = "14"
ethereumTransaction.to = "0xe5c23dAa6480e45141647E5AeB321832150a28D4"
ethereumTransaction.amount = "500000000000000"
ethereumTransaction.gasLimit = "21000"
ethereumTransaction.gasPrice = "6000000000"
ethereumTransaction.data = "0x"
ethereumTransaction.chainId = "1"

DcentMgr.getEthereumSignedTransaction(coinType:.ETHEREUM , ethereumTransaction:ethereumTransaction){ (result, txData) in
print("Ethereum Transaction closure")
if result == false {
print("FAIL !!!")
}else{
print(txData)
}
}

getTokenSignedTransaction

This function is for:

  • .ERC20 - ethereum erc20 token
  • .ETC_ERC20 - ethereum classic erc20 token
  • .ERC20_KOVAN - ethereum kovan erc20 token(ETH)
  • .ERC20_ROPSTEN - ethereum ropsten erc20 token
  • .ERC20_GOERLI - ethereum goerli erc20 token
  • .ERC20_RINKEBY - ethereum rinkeby erc20 token
  • .FLR20_COSTON - flare network coston token
  • .RRC20 - rsk smart bitcoin rrc20 token
  • .RRC20_TESTNET - rsk smart bitcoin testnet rrc20 token
  • .XRC20 - xdc network xrc20 token
  • .XRC20_APOTHEM - xdc apothem xrc20 token
  • .BEP20 - binance smart chain bep20 token
  • .BEP20_TESTNET - binance smart chain testnet bep20 token
  • .POLYGON_ERC20 - polygon erc20 token
  • .POLY_ERC20_TEST - polygon testnet erc20 token
  • .CH20 - other evm networks erc20 token

Parameters

  • coinType: erc20 type
  • tokenTransaction: (TokenTransaction)erc20 token transaction parameter

class TokenTransaction

NameTypeDescription
addressPathStringsign key path for ethereum transaction
nonceStringaccount nonce for ethereum transaction
toStringrecipient's address of ethereum transaction
amountStringamount of ether to be sent. ( wei unit value )
gasLimitStringgas limit value of ethereum transaction
gasPriceStringgas price for ethereum transaction
dataStringtransaction data of ERC20 transaction
chainIdStringchain id
symbolStringsymbol of fee account for ERC20 transaction
tokenNameStringtoken name of contract for ERC20 transaction
contractAddressStringaddress of contract for ERC20 transaction
decimalsStringdecimals of contract for ERC20 transaction
tokenSymbolStringsymbol of contract for ERC20 transaction

Returns

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

Requirements

Example

let erc20Transaction : TokenTransaction = TokenTransaction(addressPath: "", nonce: "", to: "", amount: "", gasLimit: "", gasPrice: "", data: "", tokenName: "", contractAddress: "", decimals: "", tokenSymbol: "")

// test data
erc20Transaction.addressPath = "m/44'/60'/0'/0/0"
erc20Transaction.nonce = "14"
erc20Transaction.to = "0xe5c23dAa6480e45141647E5AeB321832150a28D4"
erc20Transaction.amount = "60000000000000000"
erc20Transaction.gasLimit = "70000"
erc20Transaction.gasPrice = "3000000000"
erc20Transaction.data = ""
erc20Transaction.chainId = "1"
erc20Transaction.tokenName = "OmiseGO"
erc20Transaction.contractAddress = "0xd26114cd6ee289accf82350c8d8487fedb8a0c07"
erc20Transaction.decimals = "18"
erc20Transaction.tokenSymbol = "OMG"

DDcentMgr.getTokenSignedTransaction(coinType:.ERC20, tokenTransaction:erc20Transaction){ (result, txData) in
print("ERC20 Token Transaction closure")
if result == false {
print("FAIL !!!")
}else{
print(txData)
}
}

getMessageSign

Get the sign value of "EVM" message sign(personal_sign & signTypedData).

This function is for:

  • .ETHEREUM - ethereum (ETH)
  • .ETH_CLASSIC - ethereum classic (ETC)
  • .ETH_KOVAN - ethereum kovan (ETHt)
  • .ETH_ROPSTEN - ethereum ropsten (ETHt)
  • .ETH_GOERLI - ethereum goerli (ETHt)
  • .ETH_RINKEBY - ethereum rinkeby (ETHt)
  • .FLR_COSTON - flare network coston (CFLR)
  • .RSK - rsk smart bitcoin (RBTC)
  • .RSK_TESTNET - rsk smart bitcoin testnet (RBTCt)
  • .XDC - xdc network (XDC)
  • .XDC_APOTHEM - xdc apothem (XDCt)
  • .BSC - binance smart chain (BNB)
  • .BSC_TESTNET - binance smart chain testnet (BNBt)
  • .POLYGON - polygon (MATIC)
  • .POLYGON_TESTNET - polygon testnet (MATICt)
  • .CHAN - other evm networks
  • .KLAYTN - klaytn mainnet (KLAY)
  • .KLAYTN_TESTNET - klaytn baobab (KLAYt)

Parameters

  • coinType: EVM coin type
  • messageSign: (MessageSign)evm message sign data parameter
  • isFull: (Bool) true for personal sign or eth_sign of EVM / false for signTypedData(EIP-712) of EVM

class MessageSign

NameTypeDescription
messageStringmessage for signing
keyStringsign key path for evm message sign

Returns

  • result: (Bool) true if successful, false if error occurred
  • addr: the address used to sign the data
  • sign: signed data

Example

let messageSign : MessageSign = MessageSign(message: "sign TEST!!", key: "m/44'/60'/0'/0/0")
DcentMgr.getMessageSign(coin: .ETHEREUM, messageSign: messageSign, isFull: false) { (result, addr, sign) in
if result == false {
print("FAIL !!!")
}else{
print(addr)
print(sign)
}
}