EVM based Monero Atomic Swaps
EthCC[8] · 1 Jul 2025 · 21:40
Hbs examines permissionless atomic swaps between Monero and stablecoins on EVM networks. The presentation discusses their internal operation and possible user experiences.
Speakers
Topics
From EthCC[8], hosted by Ethereum France.
Transcript
[Music] Hello everyone and welcome. I'm going to talk about uh EVM based Monero atomic swaps. Um so does any of you know what atomic swaps are? Show of hands. Okay. Okay. So, atomic swaps are uh a way of actually exchanging two cryptocurrencies from different blockchain um in a way which is entirely trustless with no third party and the atomicity is that you either manage to exchange the two
currencies or you don't and nobody can get scammed. So, that sounds like magic, right? Um so, the benefit of atomic swaps is that they are fully decentralized. They're censorship resistant. Uh they're privacy preserving. They're usually low fees because there's no third party that actually benefits from the from the swaps. And the participants at any time during the process actually retain control of their coins on both blockchains which is very important. So Monero uh who doesn't know Monero?
Okay. So, a few of you um so Monero is basically uh don't listen to Bitcoiners who would say otherwise, but the one true digital cash. It's what we like to call cipher punk money. Um it's an open- source cryptocurrency that was actually created in 2014. Uh it's private, it's anonymous, it's fully fungeible. It's a blockchain that is a proofof work uh mine using a an algorithm that's really interesting that's called random X uh which is ASIC resistant. Basically, if you want to build an ASIC to mine Monero, you have to build a CPU uh which is kind of expensive to do. Uh and in terms of economic security, there's a
tail emissioned. So forever each block will mine 0.6 6 Monero which basically is about today 0.89% of inflation which basically just covers the lost coins. So people who forget their private keys, people who die and don't actually uh transmit their their their wealth before that. So we have an incentive for miners uh that goes on forever. So Monero is actually uh anonymous and private uh due to different technologies. Uh the first one is that Monero transactions actually hide the recipients. Um Monero uses something called stealth addresses. So basically
for each transaction there's a new address that's being generated. Um and only the recipient of the transaction can actually identify the transaction as being one that's for him or for her. Um that also allows to not have any linkability between the transactions. So you cannot relate one transaction with another. Um and you have full privacy during the whole process. The second thing that Monero does to actually provide privacy is that it hides the amounts.
Uh it hides the amounts uh using something that's called ringct ring confident confidential transactions. Uh that uses Peterson commitments. Um so uh you you can determine if you are the recipient the amount that you're receiving but anybody else will not be able to see the amount. So if you look onchain uh there's no way you can actually see the amount. The only thing you can see on chain is the fee that's being paid for uh mining the transaction. Uh there's also another system called bulletproof++ that uh ensures wrench proofs and those two together ensure that there is no creation of money during a transaction.
So we know that amounts are valid within the valid range and that they actually um the the net effect of the transaction is to not create funds. So basically the amount you're spending is seen in the amount you're you're actually receiving minus the fee. Um the third thing uh that Monero does is to hide the senders. So if you look at a Monero transaction, you cannot determine who is actually sending uh the money. And the way that's done, Monero being um a UTXO based uh blockchain uh is is using what what is called ring signatures. So basically, anytime you want to spend a UTXO, one of the outputs of a previous transaction, you're going
to mix it with 15 other randomly chosen decoys. Um, and the signature of the transaction will be by one of those 16 outputs, but you're not going to be able to determine which ones, unless, of course, you're the the sender. unless you're uh uh in in in the no in the knowhow of the the actual uh private key. So that's today. Uh there's an upcoming change in Monero that will ensure that the anonymity set will not be 16 outputs but will be the entire set of outputs.
So that's a change that's going to be called full chain membership proofs plus+. And basically when you're going to spend an output uh you will only prove that you're spending one of the existing outputs uh in the whole Monero blockchain. And last thing Monero is secure of course and egalitarian. So as I've said random X is a CPU uh centric mining algorithm. So the ethos of mining which is one CPU one vote still hold for Monero. Um and in terms of security, in terms of actually hiding where transactions come from, uh there's a system called Dandelion++ that actually transfer uh an outgoing transaction from
node to node directly from one node to another in a first phase and then broadcast it uh more widely in a second phase. So you cannot determine if you're receiving a transaction because you're running a node, you cannot determine which node actually initiated the transaction. you just know that that transaction actually went uh from the previous node. Um and of course if you want to be highly secure, it's always better to run your own node and connect your wallet to your own node. Um because there are some rogue nodes uh in the wall that try to look at IP addresses.
Um so always run your your own node if you can. Uh you'll be more secure this way. Okay. So, uh, what interests us is how do we actually swap from an EVM blockchain's currency to Monero or the other way around. Uh, and that's really important because I'm sure you've all looked, all of you know Monero. Uh, you cannot find Monero on any exchange. It has been delisted. And one of the reasons why it has been delisted is because everything I've said actually worked quite well. Um, and it and it's really private and an anonymous. So, if you want to obtain Monero, you can actually uh trade it peer-to-peer
through some uh sites like RTOS swap uh where you will actually find a counterparty and maybe meet in person or send cash by mail. Uh not very convenient. Um so that's the reason why we really need uh atomic swaps if you want to have a safe and atomic way of swapping one currency from an EVM. uh blockchain to Monero or or or the other way around. Uh there are also atomic swaps that exist for Bitcoin. So if you if you're into Bitcoin and you want to swap it for Monero, uh you can go see things like uh basic swap DEX or uh or BISK uh that will allow you to actually uh swap Bitcoin for for Monero.
So EVM based Monero atomic swap. So I didn't say Ethereum uh because it really applies to any EVM based uh blockchain. So it could be um Ethereum of course, it could be any uh L2s or it could be Nosis chain uh which is interesting because the base currency of Nosis chain is a stable coin. Uh so you don't actually have to change your offer all the time to actually adapt to the changing uh price. So the idea of those uh EVM based Monero atomic swaps is to swap Monero for the native currency of the EVM chain um and not not an ERC20 token because if you look at most of the ERC20 tokens uh
maybe apart from from D they all have a freeze function. So basically you're not in control of your coins during the whole process. Um that's not the case with the native currency of the of the EVM. Uh the benefit of having those atomic swaps is that you have no fees and depending on how you would configure the swap contract, you might have no limits. Uh so if you have 1 billion dollar worth of ease and you want to change that for Monero and supposedly there's a counterparty that has that amount of Monero to sell you, which I doubt, but anyways, uh you might be able to do it. Um so the swaps uh when you do those uh EVMbased Monero atomic swaps
are managed by a smart contract. Um and there's a CLI program that can actually interact uh with a contract. So you can actually create your offers, take the offers and and and take the offer through the the whole process. And there's a web app that's being worked on uh and hopefully that will um come out before the end of the year. And of course, very important since we're we're dealing with uh potentially important amounts of money, uh there's support for hardware wallets both on the EVM side of things and potentially on the Monero side of things. Uh so the CLI I was mentioning is called Monero Swap. Um the the the URL to actually get the code uh will be uh mentioned at at on the last
slide. So uh that's basically a a very small program that allows you to take any action uh towards the smart contract. Um the goal of that atomic swap process is that it's very simple for everyone. Um so the idea is that you only need a way to interact with the smart contracts. Today it's the the actual uh CLI program. Tomorrow it's going to be a DAP. Uh, and on the Monero side of things, you only need a a Monero wallet.
So, if you have Cake Wallet, for example, on your smartphone, that's the only thing you need for the Monero side of the of the swap. Um, of course, even on the Monero side, since you're interacting with the smart contract, you might need some gas. Um, again, Nosis chain is nice because it's one of the last chains uh that has a faucet on its main net. Uh, so you can actually get free money. uh not much uh but you can still get free money which is nice. Um and beyond that free money that will allow you to actually do the first interactions with the contract uh there's a third-party funding mechanism for the Monero side of the swaps that allow you to actually rely on somebody else uh providing the deposit for for
financing the swap. Uh so how does a swap actually work? So, you are going to create an offer whether you want to buy or sell Monero. Um, you're going to actually specify the range of Monero you want to buy. So, you want to buy between 1 and 10 Monero or between a,000 and 10,000 Moneros. Uh, or if you're actually selling Monero, you have 20 Monros. So, you can sell between one and 20 for example, but no more than 20 since you don't have more than 20. Uh, you can set a a price. I for now it's mostly fixed price. Uh but the contract actually has support for interacting with a price feed oracle. So you could have dynamic pricing. So you
could say for example uh the price I'm selling for is the price of the uh oracle plus maybe 10 bucks or five bucks. Um as I've said there are some deposits that you are required to provide to actually interact with the contract and that's mainly on the sales side. it's to actually um fight spam because otherwise you could very easily just take offers and just um drain the the offer book. Uh and as I've said you have a a way to actually fund that deposit by third parties uh by just giving them a fee which is a share of the amount you would get if you're actually selling Monero.
So the way atomic swaps usually work is that you are locking the currency you're one of the currencies you're selling. Uh and that time lock actually ultimately expires and allows you to ensure that nobody gets scammed during the process. Unfortunately that doesn't exist on the Monero blockchain. So we have to do something else. Um so the protocol that was actually put together a few years back um following what the the Bitcoin community had done but adapting it to to Monero uh is working pretty nicely and it's based on actually splitting the keys to which you're going to send uh the
Monero. Um, and the half of the keys that you're not providing has to be provided when you either claim the offer and you decide to cancel or refund the offer uh if things don't go well. So, globally, you're going to generate keys and I I'll go over the the detail in the next slides. You're going to generate keys each on on each side of the swap. So, the EVM side and the Monero side. Um and the key that will be used for actually sending the Monero will be the sum of the keys. Um so by having that process uh you can ensure that you can send the Monero to an address without having the other party uh
being uh able to actually spend it for now. So they they will be able to view it, but they're not going to be able to spend it until you actually claim the offer. and and and provide uh the part of the offer that that you need. Um so if you have enough uh Monero so if you got the Monero that you expected um you can ready the offer and the other side providing the Monero can actually claim it. Uh if the amount you received is incorrect or if the Monero side didn't provide the Monero then you can ask for a refund uh and you will get your EE or your your native currency back. Um so at each point in the process uh you know that you cannot get scammed because you
will be in a position to actually either access the Monero or retrieve the east back uh when you have um so as I've said the two parties they generate keys uh each on their side they provide part of their keys um to the to the contract. Then second step, the Monero side actually sends the XMR to the computed address. Um the EVM side checks that the amount that was sent is a correct one calls ready on the offer and once ready has been called on the offer, the XMR side can actually get call claim and get the ease back and will provide the part of the key that's required uh for the
for the EVM side of the swap to access the Monero. And the last step is that they will indeed access the Monero. So if we take the actual transition between the the states, you open an offer, you might update the parameters of the offer while it's not taken. At one point, somebody will actually take the offer. Uh that will position two timeouts, T0 and T1. And from there, uh you will be able to actually make the offer progress towards its completion. So until t0 um is actually passed, the exomer side of the swap must send the monero uh to the to the swap address. Um and the EVM
side can actually either decide to refund uh or actually notice that the amount is correct and call ready. Uh once ready is called the Monero side of the swap can actually call claim and retrieve the amount of E of E or EVM currency that he sold the XMR for. Um and then the EVM side can actually access the Monero and and get the Monero that they just bought. uh if things don't go well then after T1 uh the EVM side has the ability to actually call a refund get their ETH back and by getting their ease back uh they will actually provide the key that would allow the XMR
side um to actually uh get their XMR back in case they didn't send the right amount for example uh in terms of gas cost um so there are some pretty heavy uh crypto um verifications that are done so the the the the most costly operation in the process is the refund which is roughly 1.5 million gas. Um if we are on Nosis chain this equates to 15% of a cent. So that's pretty decent. Um it's really really not much. And you see that creating a buy offer creating a sell offer is around uh 500,000 gas. Um and claiming is about 800,000. the others
are are really uh very cheap. Um so so basically if you if you are um initiating a swap from a a blank address, one that hasn't actually um used any uh interaction on the blockchain on Nosis chain, you can actually ask the faucet to drop you 5% of a of a scent and you can probably do uh three full swaps with that amount. Uh so it's pretty it's pretty decent. Um so what's next? Um so right now as I've said Monero atomic swaps are live.
Uh they're on Nosis chain. Um the CLI program actually interacts with that contract by default. For now the parameters are limiting the offers between one and 10 or one cent and $10. Uh so you cannot lose much money. Uh so you're welcome to do swaps. Uh there's also a workshop uh in the codebase that you can actually run locally without interacting with the blockchain. So without spending anything. Um the goal next is to deploy the the smart contract to other blockchains or multiple instances to the same blockchain but maybe with different parameters and you're free to do so. Um and we'll be working on a guey and an oracle price feeds for some chains. Uh so you can
actually uh benefit from that. And in the end, uh, what I actually entice you to do is to actually use Monero. Uh, first because it's fun and two because it's private. Uh, so I'll happily take any questions. Uh, if you want to donate some Monero so we can actually continue to work on that, you're welcome to do so. Uh, and the code is on codeberg codeberg.org/monoswapmonosap. Thank you. Any quick question?
There's a one question over there. Yeah, it just passed him. So, is there like a market to match orders? Um so so there's not really a market to match orders and and the reason for that is that whenever you take an order you have to generate a key locally. So the contract itself cannot match orders. Uh because otherwise the key would be generated by the contract and you would not be in custody of your funds. Uh so what the what the CLI program allows you to do is to see the open offers. Um maybe what can be added is that you
actually say well I am willing to buy Monero between this price and this price and I want to buy that amount of Monero and it could actually just list the offers that actually match uh your criteria but the the the contract itself the markets itself cannot match uh the offers because of that that key dynamics that I just explained. But there is a list of people that want their orders filled. Yes, there is a list of people who actually place some offers, but you as an individual have to take it yourself. We're not going to it's not going to be matched automatically. You have to say, I want to take this offer uh in particular.
Gotcha. Thanks. Any other questions? No, we don't have time. Sorry. We'll take it offline. Thank you very much.