# Ethereum & EVM compatible

## **getEthereumSignedTransaction**

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

**This function 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` - xcd 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: ([EthereumTransation](#class-ethereumtransaction))ethereum transaction parameter

#### **class EthereumTransaction**

<table><thead><tr><th width="209.33333333333331">Name</th><th width="143">Type</th><th>Description</th></tr></thead><tbody><tr><td>addressPath</td><td><code>String</code></td><td>sign key path for ethereum transaction</td></tr><tr><td>nonce</td><td><code>String</code></td><td>account nonce for ethereum transaction</td></tr><tr><td>to</td><td><code>String</code></td><td>recipient's address of ethereum 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 ethereum transaction</td></tr><tr><td>gasPrice</td><td><code>String</code></td><td>gas price for ethereum transaction</td></tr><tr><td>data</td><td><code>String</code></td><td>transaction data of ethereum transaction</td></tr><tr><td>chainId</td><td><code>String</code></td><td>chain id</td></tr><tr><td>symbol</td><td><code>String</code></td><td>symbol for ethereum transaction<br>symbol value used for evm chain (<code>.CHAN</code>)</td></tr><tr><td>txType</td><td><code>String</code></td><td>(optional)Type of ethereum transaction</td></tr><tr><td>maxPriorityFpg</td><td><code>String</code></td><td>(optional)max_priority_fpg of ethereum transaction</td></tr><tr><td>maxFeePerGas</td><td><code>String</code></td><td>(optional)max_fee_per gas of ethereum transaction</td></tr><tr><td>accessList</td><td><code>String</code></td><td>(optional)access_list of ethereum transaction</td></tr></tbody></table>

### **Returns**

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

### **Requirements**

* Refer to "[D\`CENT Firmware Update History](https://dcentwallet.com/support/FirmwareUpdate)" to determine which D'CENT Biometric Wallet versions are supported on each network.

**Example**

```swift
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 fuction 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` - xcd 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: ([TokenTransation](#class-tokentransaction))erc20 token transaction parameter

#### **class TokenTransaction**

<table><thead><tr><th width="197.33333333333331">Name</th><th width="129">Type</th><th>Description</th></tr></thead><tbody><tr><td>addressPath</td><td><code>String</code></td><td>sign key path for ethereum transaction</td></tr><tr><td>nonce</td><td><code>String</code></td><td>account nonce for ethereum transaction</td></tr><tr><td>to</td><td><code>String</code></td><td>recipient's address of ethereum 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 ethereum transaction</td></tr><tr><td>gasPrice</td><td><code>String</code></td><td>gas price for ethereum transaction</td></tr><tr><td>data</td><td><code>String</code></td><td>transaction data of ERC20 transaction</td></tr><tr><td>chainId</td><td><code>String</code></td><td>chain id</td></tr><tr><td>symbol</td><td><code>String</code></td><td>symbol of fee account for ERC20 transaction</td></tr><tr><td>tokenName</td><td><code>String</code></td><td>token name of contract for ERC20 transaction</td></tr><tr><td>contractAddress</td><td><code>String</code></td><td>address of contract for ERC20 transaction</td></tr><tr><td>decimals</td><td><code>String</code></td><td>decimals of contract for ERC20 transaction</td></tr><tr><td>tokenSymbol</td><td><code>String</code></td><td>symbol of contract for ERC20 transaction</td></tr></tbody></table>

### **Returns**

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

### **Requirements**

* Refer to "[D\`CENT Firmware Update History](https://dcentwallet.com/support/FirmwareUpdate)" to determine which D'CENT Biometric Wallet versions are supported on each network.

**Example**

```swift
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 fuction 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` - xcd 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](#class-messagesign))evm message sign data parameter
* isFull: (Bool) `true` for personal sign or the\_sign of EVM / `false` for signTypedDatt(EIP-721) of EVM

#### **class MessageSign**

<table><thead><tr><th width="123.33333333333331">Name</th><th width="125">Type</th><th>Description</th></tr></thead><tbody><tr><td>message</td><td><code>String</code></td><td>message for sigining</td></tr><tr><td>key</td><td><code>String</code></td><td>sign key path for evm message sign</td></tr></tbody></table>

### **Returns**

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

**Example**

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