r/ethdev • u/DayKnown1050 • 26d ago
Information Things I'd check before a crypto withdrawal service touches real funds
Withdrawals are where crypto backends lose real money, because once a transaction is out there's no undo. Here's what I'd check.
One nonce manager per hot wallet. If two workers sign from the same address, you get nonce collisions and stuck or replaced transactions. Track nonces in your own database instead of trusting eth_getTransactionCount on a load-balanced RPC.
Idempotent requests. Every withdrawal gets an ID with a unique constraint, so a retry can never create a second payout.
Save the signed transaction before you broadcast it. If the process crashes right after sending, you want to rebroadcast the same transaction on restart, not sign a new one with a new nonce.
Plan for stuck transactions. To speed one up you replace it with the same nonce and higher fees. Geth, for example, needs both fee fields at least 10% higher. Track by nonce, not hash, since either the old or the new transaction can end up mined.
Validate the destination. Checksum the address, block sends to token contract addresses, and remember the same address format works on every EVM chain. Users picking the wrong network will happen.
Limits and review. Per-user and daily limits, manual approval above a threshold, and a cooldown on newly added withdrawal addresses. That last one helps a lot against account takeovers.
Keep the hot wallet small. Hold roughly what you need for a day and keep the rest in cold storage. Also keep enough ETH in it for gas, or every token withdrawal fails.
Reconcile daily. Compare ledger debits with actual on-chain outflows, and alert on any gap.
What did I miss? Curious how people handle fee bumping on L2s.
1
u/Nico-Hartmann 26d ago
On L2s I've had better luck with cancel and resend instead of standard replacement. Arbitrum and Optimism both let you send a zero value tx to yourself with the same nonce and higher gas, then the new withdrawal goes out clean after that clears. The catch is you need to know the exact base fee the sequencer is seeing at that moment, otherwise the bump tx sits there too. We ended up polling the rollup's gas oracle endpoint every few seconds and baking that into the fee calc before signing anything. Not perfect but it stopped the stuck queue from piling up during spikes.
1
u/Bloqarl 25d ago
On fee bumping, Iād reconcile by wallet and nonce, not tx hash. A bump gives the same payout a second hash, so if your watcher marks the first one as dropped and re-queues it with a new nonce, you pay twice. On Arbitrum the tip does nothing, first come first served, so a stuck tx there is usually a nonce gap
1
u/Fun-Scheme-8448 25d ago
two things we ended up hardcoding into our frontend destination checks because users kept shooting themselves in the foot: first, blocking withdrawals where the destination address is the token contract itself (usdc, weth, etc) or the protocol vault address. you would be amazed how many people go to etherscan or basescan to copy an address and accidentally copy the token contract address instead of their own wallet. second, checking eth_getCode on the destination address for the 0xef0100 prefix before sending. since eip-7702 went live, if a user's EOA got hit by a delegated sweeper, it still looks like a normal EOA to them, has 0 balance, and the second their withdrawal lands it gets swept in the next block. warning them that their destination EOA has active 7702 code attached saves a lot of heartbreak.
1
u/Lushniak_Masjid 25d ago
Adding a hrad rule that two human approve any change to the address allowlist, because attackers aim at thhe policy instead of the wallet. I also reconcile every hour instead of daily, since a small hot wallet only if you notice the leak fast.
1
u/grahamhart_ 7d ago
One thing I add before any real withdrawal is a quick risk check on the destination address itself. I run it through Scorechain so I can see mixer, scam, or sanctioned exposure right away and catch bad destinations before the transaction is even signed. That extra step has stopped a couple of problems that the usual address and limit checks would have missed.
1
u/[deleted] 26d ago
[removed] ā view removed comment