Using an Ethereum wallet to sign transactions on Waves

Array Clean
Gravity Protocol
Published in
4 min readFeb 26, 2021

This article reveals the concepts of mirror accounts and delegation gateways, enabling the use of a wallet bound to a particular blockchain, such as Metamask to Ethereum, to seamlessly interact with other blockchain networks.

This is a brief overview of a new instrument that will further advance inter-chain tech. Today, we are presenting a safe and secure way to use a wallet bound to a particular blockchain, such as Metamask and Ethereum, to seamlessly interact with other blockchain networks. It uses the concept of delegation gateways, made available through the Gravity network, and so-called mirror accounts.

Mirror accounts

We are glad to introduce a key innovation aimed at lowering blockchain fees and streamlining user experience — mirror accounts. The technology that underlies this concept is very simple. Each user has two blockchain accounts:

  • The main account in the origin chain with some tokens on the balance
  • A mirror account, which is dynamically created by the system when the user attempts to interact with a blockchain that is non-native to the wallet they’re using. This account matches the transactions signed by an Ethereum account owner in a destination chain, such as Waves

This mechanism provides a single blockchain account that is capable of accessing various functions on each chain which supports the creation of mirror accounts. In that sense, we are not restricted to EVM-based chains compatible with Ethereum smart contracts, which is important to extend interchain technologies beyond the Ethereum ecosystem.

Why Waves

The reason to choose Ethereum as an origin chain is, first and foremost, its popularity: the majority of users in DeFi belong to the Ethereum ecosystem, providing traction and liquidity. However, Ethereum gas fees are currently exorbitantly high for regular users to afford execution of smart contracts.

On the other hand, the Waves blockchain has significantly lower, fixed transaction fees, meaning that a Waves mirror account can be used to affordably execute smart contracts, perform computations and keep the state.

Implementation details

Demo

In this demo, Metamask is used for signing transactions with Ethereum private keys. The demo is currently hosted here.

Generation of a new Waves seed in the browser

waves account generation from our example sources

The first necessary action in the system is creating a new Waves account via the Waves API. To proceed further, it is also required for the mirror account to somehow obtain a small amount of Waves for transaction fees. This is a non-trivial issue which is currently resolved through a so-called transaction fee controller but might be solved through other means in the future.

Note: Creating a new mirror account in Waves is invoked as an off-chain procedure but it is secure nevertheless because it uses a native Waves library.

Deploying smart accounts

The implementation of mirror accounts in Waves provides utmost security due to the smart account functionality. Each smart account can carry its own transaction verification logic, for instance, forbidding transactions that exceed a certain amount threshold, or verifying the transaction sender. In this case, a Ride function ecrecover can be used to verify that the signature generated by the owner of an Ethereum account corresponds to the public key of this account.

The main benefit of using a Waves smart account is the ability to hand the private key over to the mirror account.

Note: the Metamask API method personal_sign modifies data by appending a prefix before signing, which means that the contract on the mirror account should conduct a similar byte modification. Only base64 Waves transaction data can be sent. If required, it can easily be decoded to see the transaction details.

Sending transactions on Waves

In closing, this combination of delegation gateways and mirror accounts allows for sending any types of transactions on Waves using Metamask on the frontend, opening up endless opportunities to improve interchain user experience.

Demonstration

Conclusion

We believe that this system that uses Gravity is an important step towards a more seamless interchain experience. In the future, it can be extended to allow for interaction with other blockchain networks, such as BSC, Tron, Avalanche, Fantom, and Heco. This technology provides a new important way that can connect more blockchains together, making the usage of cross-chain tech seamless and coherent to the end users.

References

--

--