# Precompiles

## Currency Swap precompile

Use this precompile to transfer the funds from your EVM account to any Native account.

<table><thead><tr><th width="150">Property</th><th width="583.1428571428571">Description</th></tr></thead><tbody><tr><td>Address</td><td><code>0x0000000000000000000000000000000000000900</code></td></tr><tr><td>Input</td><td>See contract interface.</td></tr><tr><td>Output</td><td>See contract interface.</td></tr></tbody></table>

### Contract interface

<https://github.com/humanode-network/humanode/blob/master/crates/precompile-currency-swap/CurrencySwap.sol>

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

## Bioauth status check precompile

Use this precompile to check if the specified address has an active bioauth. Takes the validator public key (type `AccountId` in the Humanode runtime code, also known as native - or Substrate - account).

<table><thead><tr><th width="150">Property</th><th width="583.1428571428571">Description</th></tr></thead><tbody><tr><td>Address</td><td><code>0x0000000000000000000000000000000000000800</code></td></tr><tr><td>Input</td><td><code>AccountId</code> (Substrate account address); 32 bytes<br>The public key to check.</td></tr><tr><td>Output</td><td><code>bool</code>; 1 byte<br><code>1</code> if bioauth is active for the address, <code>0</code> if bioauth is inactive for the address.</td></tr></tbody></table>

### Helper Library

You can use the helper library below together with your smart contract code to simplify invoking the precompile.

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

pragma solidity ^0.8.0;

library bioauth {
    function isAuthenticated(bytes32 accountId) public view returns (bool result) {
        address precompile = 0x0000000000000000000000000000000000000800;
        bytes memory payload = abi.encodePacked(accountId);
        (bool success, bytes memory returnData) = precompile.staticcall(payload);
        assert(success);
        assert(returnData.length == 1);
        return (returnData[0] != 0);
    }
}
```

## EVM to native account mapping precompile

Use this precompile to find a corresponding mapped native `AccountId` for provided EVM address. This is useful to be used in combination with `Bioauth` precompile as you don't need to worry about a proper `AccountId` to do bioauth check.

Description

<table><thead><tr><th width="150">Property</th><th width="583.1428571428571">Description</th></tr></thead><tbody><tr><td>Address</td><td><code>0x0000000000000000000000000000000000000801</code></td></tr><tr><td>Input</td><td><code>evmAddress</code> (EVM address); 20 bytes</td></tr><tr><td>Output</td><td><p><code>(bool, bytes32)</code>; </p><ul><li><code>(true, 0x12..9)</code>: indicates that the evm adress has been mapped where <code>0x12..9</code> is the mapped native account itself. </li><li><code>(false, 0x00..0)</code>: indicates that the evm addres hasn't been mapped.</li></ul></td></tr></tbody></table>

### Helper Library

You can use the helper library below together with your smart contract code to simplify invoking the precompile.

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

pragma solidity ^0.8.0;

library evmAccounts {
    function claimedNativeAccount(bytes20 evmAddress) public view returns (bool, bytes32) {
        address precompile = 0x0000000000000000000000000000000000000801;
        bytes memory payload = abi.encodePacked(evmAddress);
        (bool success, bytes memory returnData) = precompile.staticcall(payload);
        assert(success);
        if (returnData.length == 0) {
            return (false, 0x0);
        } 
        bytes32 nativeAccount = abi.decode(returnData, (bytes32));
        return (true, nativeAccount);
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.humanode.io/docs/evm/precompiles.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
