# Ethereum & EVM compatible

## **getEthereumSignedTransaction**

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

**This function for :**

* `ETHEREUM` (ETH) - ethereum
* `ETH_CLASSIC` (ETC) - ethereum classic
* `ETHEREUM_GOERLI` (ETHt) - etheruem goerli
* `FLARE_COSTON` (CFLR) - flare network coston
* `RSK` (RBTC)- rsk smart bitcoin
* `RSK_TESTNET` (RBTCt) - rsk smart bitcoin testnet
* `XDC` (XDC) - xdc network
* `XDC_APOTHEM` (XDCt) - xdc apothem
* `BSC` (BNB) - binance smart chain
* `BSC_TESTNET` (BNBt) - binance smart chain testnet
* `POLYGON` (MATIC) - polygon
* `POLYGON_TESTNET` (MATICt) - polygon testnet
* `ETH_CHAIN` - other evm networks

### **Parameters**

| Parameter   | Type                                              | Description                      |
| ----------- | ------------------------------------------------- | -------------------------------- |
| coinType    | `CoinType`                                        | ethereum coin type.              |
| transaction | [EtheruemTransaction](#class-ethereumtransaction) | ethereum transaction parameters. |

#### **class EthereumTransaction**

<table><thead><tr><th width="183.33333333333331">Name</th><th width="163">Type</th><th>Description</th></tr></thead><tbody><tr><td>hdKeyPath</td><td><code>Bip44KeyPath</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>toAddr</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>int</code></td><td>chain id</td></tr><tr><td>symbol</td><td><code>String</code></td><td>symbol of contract for ethereum transaction</td></tr><tr><td>tx_type</td><td><code>byte</code></td><td>(optional)Type of ethereum transaction</td></tr><tr><td>max_priority_fpg</td><td><code>String</code></td><td>(optional)max_priority_fpg of ethereum transaction</td></tr><tr><td>max_fee_per_gas</td><td><code>String</code></td><td>(optional)max_fee_per gas of ethereum transaction</td></tr><tr><td>access_list</td><td><code>String</code></td><td>(optional)access_list of ethereum transaction</td></tr></tbody></table>

### **Returns**

`String` - 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**

```java
EthereumTransanction ethereumTransanction;
ethereumTransanction = new EthereumTransanction.Builder()
                .keyPath(Bip44KeyPath.valueOf("m/44'/60'/0'/0/0"))
                .nonce("14")
                .toAddr("0xe5c23dAa6480e45141647E5AeB321832150a28D4")
                .amount("500000000000000")
                .gasLimit("21000")
                .gasPrice("6000000000")
                .data("0x")
                .chainId("1")
                .symbol("ETH")
                .build();
String response = mDcentmanager.getEthereumSignedTransaction(CoinType.ETHEREUM, ethereumTransanction);
```

## getTokenSignedTransaction

**This function for :**

* `ERC20` - ethereum erc20 token
* `ETC_ERC20` - ethereum classic erc20 token
* `ERC20_KOVAN` - etheruem kovan erc20 token
* `ERC20_ROPSTEN` - etheruem ropsten erc20 token
* `ERC20_GOERLI` - etheruem goerli erc20 token
* `ERC20_RINKEBY` - etheruem rinkeby erc20 token
* `FRC20_COSTON` - flare network coston token
* `RRC20` - rsk smart bitcoin token
* `RRC20_TESTNET` - rsk smart bitcoin testnet token
* `XRC20` - xdc xrc20 token
* `XRC20_APOTHEM` - xdc apothem xrc20 token
* `BSC_BEP20` - binance smart chain bep20 token
* `BSC_BEP20_TESTNET` - binance smart chain bep20 testnet token
* `POLYGON_ERC20` - polygon erc20 token
* `POLYGON_ERC20_TESTNET` - polygon erc20 testnet token
* `ECH_ERC20` - other evm erc20 token

### **Parameters**

| Parameter   | Type                                        | Description                   |
| ----------- | ------------------------------------------- | ----------------------------- |
| coinType    | `CoinType`                                  | erc20 type.                   |
| transaction | [TokenTransaction](#class-tokentransaction) | token transaction parameters. |

#### **class TokenTransaction**

<table><thead><tr><th width="187.33333333333331">Name</th><th width="161">Type</th><th>Description</th></tr></thead><tbody><tr><td>hdKeyPath</td><td><code>Bip44KeyPath</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>toAddr</td><td><code>String</code></td><td>address to send</td></tr><tr><td>amount</td><td><code>String</code></td><td>amount of ETH to send</td></tr><tr><td>gasLimit</td><td><code>String</code></td><td>gas limit value</td></tr><tr><td>gasPrice</td><td><code>String</code></td><td>gas price for ethereum 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>symbol</td><td><code>String</code></td><td>symbol of contract for ERC20 transaction</td></tr><tr><td>chainId</td><td><code>String</code></td><td>chain id</td></tr><tr><td>feeSymbol</td><td><code>String</code></td><td>symbol of fee Account for ERC20 transaction</td></tr></tbody></table>

### **Returns**

`String` - 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**

```
TokenTransaction erc20transaction;
erc20transaction = new TokenTransaction.Builder()
                .keyPath(Bip44KeyPath.valueOf("m/44'/60'/0'/0/0"))
                .nonce("14")
                .toAddr("0xe5c23dAa6480e45141647E5AeB321832150a28D4")
                .amount("60000000000000000")
                .gasLimit("70000")
                .gasPrice("3000000000")
                .tokenName("OmiseGO")
                .contractAddress("0xd26114cd6ee289accf82350c8d8487fedb8a0c07")
                .decimals("18")
                .symbol("OMG")
                .chainId("1")
                .feeSymbol("ETH")
                .build();

String response = mDcentmanager.getTokenSignedTransaction(CoinType.ERC20, erc20transaction)
```

## getEthereumMessageSigned

Get the sign value of "EVM" message sign(personal\_sign & signTypedData).

**This function for :**

* `ETHEREUM` (ETH) - ethereum
* `ETHEREUM_GOERLI` (ETHt) - etheruem goerli
* `RSK` (RBTC)- rsk smart bitcoin
* `RSK_TESTNET` (RBTCt) - rsk smart bitcoin testnet
* `XDC` (XDC) - xdc network
* `XDC_APOTHEM` (XDCt) - xdc apothem
* `BSC` (BNB) - binance smart chain
* `BSC_TESTNET` (BNBt) - binance smart chain testnet
* `POLYGON` (MATIC) - polygon
* `POLYGON_TESTNET` (MATICt) - polygon testnet
* `ETH_CHAIN` - other evm networks
* `KLAYTN` (KLAY) - klaytn
* `KLAY_BAOBAB` (KLAYt) - klaytn baobab

### **Parameters**

<table><thead><tr><th width="139.33333333333331">Parameter</th><th width="198">Type</th><th>Description</th></tr></thead><tbody><tr><td>coinType</td><td><code>CoinType</code></td><td>coin type.</td></tr><tr><td>transaction</td><td><a href="#class-ethmessagesigndata">EthMesageSignData</a></td><td>ethereum message sign data parameters.</td></tr><tr><td>command</td><td><code>String</code></td><td>data sign command.(<code>"msg_sign"</code> | <code>"sign_data"</code>)<br>- <code>"msg_sign"</code> for personal_sign or 'eth_sign' of EVM<br>- <code>"sign_data"</code> for signTypedData(EIP-721) of EVM</td></tr></tbody></table>

#### **class EthMessageSignData**

<table><thead><tr><th width="139.33333333333331">Name</th><th width="164">Type</th><th>Description</th></tr></thead><tbody><tr><td>hdKeyPath</td><td><code>Bip44KeyPath</code></td><td>sign key path for ethereum sign data transaction</td></tr><tr><td>data</td><td><code>String</code></td><td>message for signing</td></tr></tbody></table>

### **Returns**

`HashMap<String, String>` - signedData{address,sign}

### **Requirements**

* D'CENT Biometric Wallet version 1.3.0. or higher is required.
  * (for EIP-721) version 2.11.1. or higher is required.

**Example(ethereum personal\_sign)**

```java
EthMesageSignData ethMesageSignData;
ethMesageSignData = new EthMesageSignData.Builder()
                    	.keyPath(Bip44KeyPath.valueOf("m/44'/60'/0'/0/0"))
                    	.data("Message Sign TEST")
                    	.build();
HashMap<String, String> response = mDcentmanager.getEthereumMessageSigned(CoinType.ETHEREUM, ethMesageSignData, "msg_sign");
String address = response.get("address");
String sign = response.get("sign");
```
