DApp Off-Chain Components: Starter Pack

EDCON 2026 · 17 Oct 2026 · 19:44

Wen Kang Chen, CTO of enhanced.finance, presents a starter pack for the off-chain components of a DApp at EDCON 2026. The 30-minute talk is a developer-focused introduction to the parts of a decentralised application that sit outside the smart contracts.

Speakers

Topics

From EDCON 2026, hosted by De University of Ethereum (UETH).

Transcript

Good afternoon. Uh So yeah, hi, I'm Wenkang. And uh yeah, today I'm going to be talking a little bit about um dApp off-chain components, right? I call it a starter pack, but um well, let's just take a quick look. So um we often talk a lot about smart contracts, architecture and whatnot, but I think um you know, the off-chain part of every dApp protocol also deserves some love. So today I'm here to talk about it. So two There's two main uh components that I want to bring into focus here. So usually usually uh when you run a dApp and whatnot, you will have a oftentimes have a relayer um

mainly help you uh do things relay things, relay transaction and whatnot. So well, it can be a lot of things, but here you can be used for for example, signing transactions on behalf of users and whatnot. And you also usually have the indexer which uh effectively listens to events of your smart contract on-chain. Uh it can also be well, indexing just transactions, monitoring blocks depending on what your use case is. So today I will be mainly talking about um the nonce management part of uh a relayer that does it. Um yeah, I won't be talking much about indexer today. [snorts] So nonce management

um before I dive deep into uh what how how to do nonce management, not like uh what are the techniques to do it, um let's start a little bit on like what a nonce is. Um I'm sure a lot of you already know what it is, but you know, humor me. Um so yeah, uh nonce usually is just the Well, it's a counter that your address, your wallet address, your address use to know uh which like how many transactions you have sent, uh what is the current It used to identify the numbering of your transaction, right? For example, if you send um five transaction in your lifetime, then your nonce will likely be five.

So it's mainly there um to basically show ordering and also to prevent replay protection. So no one can submit your transaction twice and attempt to do the same state changes. So there are a few rules usually uh when when you deal with nonces is uh usually yeah again to prevent replay replay uh attacks, right? So usually it's sequential and it's it's blocking in the sense here it says blocking, but it's blocking in the sense that usually you cannot skip over numbers of uh for your nonces. Meaning for example, if you send a transaction with nonce five and you later send a transaction with nonce seven, uh the non the transaction with nonce

seven would not run until something comes in at six. So yeah that's what locking means here. So now going into usually what you encounter as a user of a dapp, a user of a DeFi app, you know whatever Uniswap, you know be it Alchemix um what happens is usually you will use a wallet and your wallet handles it for you. So what happens? Well, your wallet usually when you they want you to sign a transaction, you'll get a prompt a notification a small window where um you'll be told to sign something.

Usually an approval request, a transfer request, a swap request, whatever, right? It depends on what you are doing. So you sign it it'll be sent to an RPC node in some server somewhere and if you do not configure your own, it will be sent to probably MetaMask own server and their own RPC node. If you care about privacy, set up your own. Um and once it lands um and it goes through correctly then yeah voila your swap happens. If it doesn't well, you usually just get oh yeah your transaction fails and what you usually will do is you'll just click the button again, the entire process starts again and it goes through, right? And

hopefully it goes through, right? If it doesn't go through, you try again and get frustrated and complain on Twitter. I think. Um so yeah, that's what usually happens. But for example, in cases where um let's say you are you run an operator and then you help your user sign certain transactions or you just run a backend services that um has certain operations. Um for example, in our case, uh let's say you hold users fund and the process of um withdrawing their funds to to another contract for U generation or whatnot uh requires like it's a high security endeavor.

So it you don't want it to be easily done. You don't want people to drain your contract uh when you are moving funds that are important to your users. So in those cases um you do need to also do a signature, right? On transactions. But in this case, you you you don't really want to um go through a wallet and you usually will go through things a little bit more secure like uh key management system or just uh custodian, right? Fireblocks and whatnot. So in those cases, you're signing without a UI.

And they they yeah, operator usually they just sign on user behalf or there's an extra layer of security, right? Um as I what what I just said. So the naive way of doing this, which is um I think well it's there's nothing wrong with this um and it's what usually uh in the front end you can just do this very simply as well. Um is you just I believe this is also what happens for most wallet implementation as well. It's you just call for a um pending transaction count. So uh your to get your latest transaction count in in your for your address, right?

And once you get that, you can use that to submit a new transaction. So this works most of the time for uh even you are sending multiple transactions at the time, even your transactions doesn't fail. So, um this is what a naive way of doing it and again, since it works most of the time, you can just use this wherever, um but it does break uh as I said when you have transaction six, uh seven and eight for example, um and seven fails, your transaction eight will likely also fail with it um because the nonces in between is incorrect um or it's missing or it's failing uh it's not reverting. Reverting

consumes the nonce. But yeah, you get the point. So, um this is not ideal in something like a system where you are not working with a wallet and you want your trans your submitted transaction to very easily retry and hopefully not fail just because you got the nonces wrong. You want to be able to retry if if this happen and also there's a few cases that we will deep dive into.

So, um yeah, usually when you submit a transaction and it fails, it's usually in a few cases first is reverted. In the case where the transaction reverts, it does consume the nonce. So, you don't need to worry too much. Um you just have to submit a transaction with a new nonce uh if your transaction is not you you don't require your transactions to be sequential. Um so, for the second case where it's rejected, meaning uh either you did not pay your RPC bill and it just tells you, hey, pay your bill, we are not going to let your transaction through, or you will get rate limited, which is very common if you're using free RPCs or you just have to pay more.

Uh and some crimes you just don't have enough funds in your wallet, you will also get just rejected um and a few cases, right? In these cases, your nonces will get not get consumed. So, if you increment your nonce or if you assume that uh you have a reuse the nonce, you might submit transaction where it will be stuck in the mempool uh until you fill up the gaps. And finally, yeah, it's you submitted the transaction but um there is a your max fee per gas just fell under the base fee. So no one is picking up your transaction.

In those cases um usually you will want to either cancel it or just replace it with a higher fee. So this is generally the three cases we care about in nonce management. So since just getting the latest uh transaction count doesn't work, let's go into something better. So we can use something called uh nonce manager. Well, um it's just a uh piece of code, a service that manages your nonce, right? So the main point of having this is effectively we want to keep account ourselves. We don't want to trust what's returned back from the RPC node only.

Um so in these cases usually you still start off by getting the pending count or the latest count from your RPC node and then you keep track of it locally. You make sure so every time you send a transaction you consult this, you get the latest count from your local storage and then you submit your transaction. So at the same time you also do need to store your unsigned transaction. This is mainly for the sake of retries. So if it fails you can retry it with the same nonce or different nonce depending depending on the failure case for your transaction.

And another thing that you have to implement so this is a very simple code probably from VM if I'm not wrong um the library uh for your uh contracts effectively, smart contracts right? So another thing you have to handle as well is uh to manage the gaps between your transaction. So in cases where for example you submitted three four transactions at once um and they're all in the mempool and let's say three of them go through and one of them fails or you just submitted all them all at once and just one of them fails and return back just telling you hey you know it's rejected.

You do have to submit again to make sure that there's no gaps again if there's any gaps it will get stuck in the mempool and wait for a certain period of time depending on the implementation of the client until it gets dropped or it just waits there forever right. So yeah so this is just a deeper view on how the flow looks like so yeah when it gets rejected you know just resign send it's fine. When you get stuck just replace it or you can just cancel it.

A cancellation in this case just works by sending a transaction with a transfer transaction to yourself with the same nonce with zero fees sorry zero yeah zero transfers. I might have worded that wrongly and well in the case there's a case here which is reorg if you submit a transaction and somehow the chain reorged you do have to handle that because it just gets returned into the mempool as well and this is rare to encounter but yeah you do have to handle this case as well but you should keep track of where your submitted transaction is so

you can very easily retry and you know where to retry from and if there's any failure your monitoring can catch it right. Okay so this I've actually already mentioned just how how to handle a stuck transaction in general yeah the same same nonces increase the fees or just canceling it. So let's dive a little bit deeper so in most production systems very likely you will have some sort of secure signing and also very likely depending on um what level of security you need, you might also employ some sort of MPC wallet or or so on. And in terms of scaling just

to scale maybe you want to have more workers working on your transaction handling at once um just to make it slightly faster, right? So let's cover these cases. So um we I'm mainly going to be talking about KMS or like Fireblocks. So a self custody solution or a key management solution um that you will plug in to handle your keys for the extra security, right? So um usually how it will look like in general is like a very rough diagram. It's you will have a nonce manager that service that actually handles keeping track of a transaction where it is where what's the current nonce how to handle certain things and you will have

a separate service just to handle signing. Um this plugs into well again depending on what signing service is used. And when dealing with things like this um there is a problem or like especially for MPC wallets or digital custody solution where require where you require multiple signatures and you need time to collect this signature. You now have to handle this weight. So when you're dealing with EOAs, when you're dealing with single wallets with the key that you own on the machine that runs the the submission of your transaction, right?

Uh you don't really care because the signature happens instantaneously right? However, for cases like this where you are delegating your signature to other parties to sign again just do the same thing as what we've mentioned in the very simple case of having a nonce manager. But now you now have to keep in mind that you have to wait. So you can't just send uh wait for it to come back and then continue. It will block your entire operation. So in these cases just I mean it's the the thing. If you already track all your transaction just make sure to track each status of it, poll it, make sure if it works, if it goes through and you can submit it.

Um, otherwise you know just um if it fails, yeah. Otherwise just you should go well, right? Uh this you do additionally have to handle timeouts. So there are cases where maybe for especially for MPC where you do need to wait sometimes a few hours, little unlikely but usually called in it, but up to an hour let's just say uh for everyone to sign and for the transaction to be approved right?

So you do have to decide how long you want to wait. You know it's is it uh if after you wait that long, what happens, right? You can reserve a nonce for it um but again in these type of cases where there is a wait the submission gets a little bit completed. You want to be able to only isolate these kind of operations to like the things that matter the most and things that can wait.

Don't use the same thing for like things that cannot wait. So um usually what I do here or what what we've implemented is just a it's just a list that waits, right? For MPC especially. We just wait for the previous one to go through to fully approve and then or like wait until like a certain short timeout um before we proceed to try another one with the same nonce rather than reserve it for each of them and send them batch to be signed uh because it's a little bit more complicated UX wise to [clears throat] manage this. Uh we don't really want whoever is signing it to re-sign every other transaction that comes after the failed one.

Ideally we want them to just sign once and if it goes, it goes. Um so this is one of the things that does get a little bit Well, it's not complicated. It's just that there are certain operations that requires multiple steps. Approve swaps, for example. I'm using a very simple example here. So, uh in this kind of cases, um ideally we can batch it up into one single transaction sign and then it just goes through. So, in that case we don't need to handle cases where the approver fails and the swap passes, which doesn't happen because it would just get

reverted anyways. Um but we don't want the cases where one fails, one passes. We want ideally it fails together and it goes through together. So, two two ways to do this. Permit is quite common now. So, permit approval or 7702 batching. Um this just helps you get both transactions through at the same time. Very useful UX feature to have. Um and very useful for us to manage the transaction lifecycle as well.

So, uh this is just going So, this is actually the final part probably um on dealing with multiple processes. This is when you want to scale, you want to have um well, when you want to have more non-manager handling of transactions, when you want to have more signers um handling the amount of transaction that goes through, right? So, in this case it's it's very unlikely that you will have multiple MPC signer workers doing the job because MPC just takes time. Um but let's say just KMS, right?

Um in these cases usually just, you know, just scale your signer site, have a queue, make sure the things goes in first in first out first out uh ensure the sequence and you will be fine most of the time. Um as long as you do what as long as you manage your nonsenses right for a single process, you can slowly just scale that up. Just take out components and scale components that individually and most of the time you'll be fine. So yeah, that's basically it, but would like to mention a few other failure points that I didn't mention here. So restarts as long as you have persistent memory, this

is more than fine. RPC failover. So this is when you have multiple RPC providers, multiple RPC nodes. This is also a problem we run into before, I've run into before, where you want to handle multiple RPC providers just to ensure you have the redundancy. [snorts] And in this case, do beware trust the node less, rely on your system a little bit more because you are dealing with different man pools for each node.

So yeah, and yeah, reorgs, right? I I'm not talking about reorgs here, but reorgs, there are a few cases that you you do have to be aware of, I would say. So yeah, that's it. I'm Moon Kang. I'm currently building option based structured products vaults. But otherwise, that's my Twitter handle and my email. If you have any questions, you can ask me there or you can ask me now. So yeah, thank you.

Related talks