> For the complete documentation index, see [llms.txt](https://gitbook.humanode.io/hmnd-ehmnd/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.humanode.io/hmnd-ehmnd/hmnd-ehmnd-swap-guide/ehmnd-to-hmnd.md).

# eHMND to HMND

The guide to swap eHMND to HMND.

### Tools

* Environment to deploy ethereum smart contracts like [Remix IDE](https://remix.ethereum.org/)
* Ethereum supported wallet like [Metamask](https://metamask.io)
* [Polkadot.js apps](https://gitbook.humanode.io/docs/tools-and-services/polkadotjs-apps)

### Steps

1. Open the Remix IDE and create a file containing the currency swap precompile interface.

```solidity
// SPDX-License-Identifier: UNLICENSED

pragma solidity >=0.7.0 <0.9.0;

/**
 * @title Currency Swap Interface
 *
 * An interface enabling swapping the funds from EVM accounts to
 * native Substrate accounts.
 *
 * Address: 0x0000000000000000000000000000000000000900
 */
interface CurrencySwap {
  /**
   * Transfer the funds from an EVM account to native substrate account.
   * Selector: 76467cbd
   *
   * @param nativeAddress The native address to send the funds to.
   * @return success Whether or not the swap was successful.
   */
  function swap(bytes32 nativeAddress) external payable returns (bool success);
}

```

<figure><img src="https://1431170879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhKZNwmzPYrswDUmy5yPx%2Fuploads%2FaH7XcFy3lAV1prtNwwMU%2Fimage.png?alt=media&amp;token=06596659-b821-4d1d-b84f-40813504e3ef" alt=""><figcaption></figcaption></figure>

2. Go to `compile` tab and compile the interface.<br>

   <figure><img src="https://1431170879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhKZNwmzPYrswDUmy5yPx%2Fuploads%2FNFVRCmvNOm3R7urCoicU%2Fimage.png?alt=media&amp;token=9bec7cbd-8447-45b7-96b6-f4b3a5ef8c11" alt=""><figcaption></figcaption></figure>
3. Go to deploy tab.<br>

   <figure><img src="https://1431170879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhKZNwmzPYrswDUmy5yPx%2Fuploads%2FgN5XX2M0dB4slXOKnH0A%2Fimage.png?alt=media&amp;token=092a47dd-49d1-4439-a7f1-12d05a394617" alt=""><figcaption></figcaption></figure>
4. Properly select `ENVIRONMENT`, `ACCOUNT` and `CONTRACT` fields.<br>

   <figure><img src="https://1431170879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhKZNwmzPYrswDUmy5yPx%2Fuploads%2FBm4v7v6UTYEnyaVy7E0T%2Fimage.png?alt=media&amp;token=0e20a6de-f44a-4167-bd5d-cce7e54d7043" alt=""><figcaption></figcaption></figure>
5. Use `0x0000000000000000000000000000000000000900` value as an input for `Deploy` tab at `At Address` field.<br>

   <figure><img src="https://1431170879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhKZNwmzPYrswDUmy5yPx%2Fuploads%2FtF5PYPUOtGCInze12uB6%2Fimage.png?alt=media&amp;token=9e1f90a8-6917-4167-b7e5-a4a3ee9cbbcd" alt=""><figcaption></figcaption></figure>
6. Click on `Deploy` tab and open `Deployed Contracts` tab. You will be able to see a `swap` call. The call accepts `bytes32` `nativeAddress` as an argument to send currency to.<br>

   <figure><img src="https://1431170879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhKZNwmzPYrswDUmy5yPx%2Fuploads%2FG6DJOwgCI4GshTAJeBdB%2Fimage.png?alt=media&amp;token=9b2e1ce8-a042-4318-aef7-863576eda865" alt=""><figcaption></figcaption></figure>
7. Open `Utilities` tab at Polkadot-JS apps connected to Humanode Israfel Testnet.<br>

   <figure><img src="https://1431170879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhKZNwmzPYrswDUmy5yPx%2Fuploads%2FOyphXCZDnvsESTVLKxHH%2Fimage.png?alt=media&amp;token=01088bb5-7d06-4f4d-9e81-676c267377d0" alt=""><figcaption></figcaption></figure>
8. Convert your native HMND address into `bytes32` value.<br>

   <figure><img src="https://1431170879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhKZNwmzPYrswDUmy5yPx%2Fuploads%2FCc7RAmq4vmK7mrGe4ktH%2Fimage.png?alt=media&amp;token=afdab7fa-7e0d-4262-af39-0de0a94fc02c" alt=""><figcaption></figcaption></figure>
9. Copy the value from the `hex public key` field and go back to Remix IDE. Input the value as an argument for the `swap` call. Input the amount you would like to swap into `VALUE` field. Keep in mind, that you should input the amount with 18 point decimals value in case using `Wei`.<br>

   <figure><img src="https://1431170879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhKZNwmzPYrswDUmy5yPx%2Fuploads%2FdZELWIPTBJMKux8MIU0H%2Fimage.png?alt=media&amp;token=92615132-2b19-4614-b6a9-606d543866a4" alt=""><figcaption></figcaption></figure>
10. &#x20;Finally, perform the swap by clicking on the `swap` call and confirm the transaction.<br>

    <figure><img src="https://1431170879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhKZNwmzPYrswDUmy5yPx%2Fuploads%2FLYenfEaCTWAAn60uxFaI%2Fimage.png?alt=media&amp;token=0ad85ac2-8eff-4ba9-83d2-3fe72c6f9b90" alt=""><figcaption></figcaption></figure>
11. Check the balance on the Polkadot-JS app.<br>

    <figure><img src="https://1431170879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhKZNwmzPYrswDUmy5yPx%2Fuploads%2FBXfxLEx9dJaUcIMXbSMZ%2Fimage.png?alt=media&amp;token=42bd64e5-45d7-4ec6-9598-98fa7eac00e3" alt=""><figcaption></figcaption></figure>
