Interoperability between Ethereum and MultiversX ecosystems

Integrating the Ethereum stack, including the VM and RPC, into the chain provides users with new opportunities. So far, this new realm was isolated from MultiversX. To ensure seamless interoperability between these ecosystems, additional features were developed.


Cross-VM Communication

The communication between EVM and SpaceVM requires special handling due to their different data encoding standards. To simplify the conversion process, our team has developed some user-friendly built-in functions:

EthereumToMultiversXEncodingWithMultiversXSignature
EthereumToMultiversXEncodingWithEthereumSignature
MultiversXToEthereumEncodingWithMultiversXSignature
MultiversXToEthereumEncodingWithEthereumSignature

To utilize these methods, append an ABI signature followed by one or more arguments.

Additionally, we have created master contracts for Solidity and Rust that can be inherited to facilitate cross-VM calls. Please refer to the documents attached below for further details.

The contracts manage, in a similar manner, ABI signatures for input and output parameters. An ABI signature is a comma-separated list of platform-agnostic ABI types. For a list of available ABI types, please refer to the dedicated documentation:

  • For Ethereum: Ethereum ABI Specification. Example of a complex ABI signature: “address,uint56,bytes24,bool,(uint256,uint256),(uint256[],bool,bytes,address),…”

  • For MultiversX: MultiversX ABI Specification. Example of a complex ABI signature: “Address,BigInt,bytes,bool,tuple<u64,i32>,tuple<List<u64>,…”

Developers must ensure that the input and output arguments match the parameters of the target execution environment. Use the conversion tables below to identify which data types should be used in the source environment, based on the ABI data types in the target environment.

ABI type mappings

Refer to the mappings below when calling an EVM contract:

Refer to the mappings below when calling a SpaceVM contract:

Solidity master contract

When creating smart contracts in Solidity, you may inherit the connector provided below for doing cross-VM calls:

Review the example below for a better understanding:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "./SpaceVMConnector.sol";

contract SpaceVMConnectorExample is SpaceVMConnector {

    address private spaceVMContractAddress;

    function setSpaceVMContractAddress(address contractAddress) external {
        spaceVMContractAddress = contractAddress;
    }

    function pingSpaceVM(uint32 value) public returns (bool, uint32) {
        require(spaceVMContractAddress != address(0));

        (bool success, bytes memory output) = callSpaceVM(spaceVMContractAddress, "ping", "u32", "u32", abi.encode(value));
        if (!success) {
            return (false, 0);
        }
        return (true, abi.decode(output, (uint32)));
    }

}

In the example provided, the ping method is invoked on a SpaceVM contract. The u32 parameters for the destination contract convert to uint32 in Solidity due to the predefined ABI data types mapping inserted in the previous subsection. Through utilizing Solidity's abi encoding and decoding functions, the caller ensures arguments are passed using Ethereum's encoding standard.


Cross-Ecosystem Transfers

OneFinity enables ETH-to-MVX and MVX-to-ETH transfers utilizing a system-level smart contract. Unlike traditional tools, which only support address-to-address transfers within the same format, our solution offers enhanced flexibility.

The contract's details are:

  • Address: one1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq9lllsjtkurw.

  • Expected payload: crossAddressTransfer@hexAddress@addressIdentifier. The hexAddress parameter represents the target address, in hex format (whether it is an Ethereum or a MultiversX one). The addressIdentifier parameter represents the type of the hexAddress and should have one of the following values: 0001 (for MultiversX addresses) or 0002 (for Ethereum addresses).

Explore the Cross-Ecosystem Transfers dApp for more details (choose the appropriate environment here). Users can log in using either Metamask or OneFinity's Lite Wallet.

Last updated