Decoding SCW swaps

With smart contract wallets (SCWs), swaps take a very different path than with traditional Ethereum/EVM wallets. That difference can be confusing, especially when something goes wrong. But once you understand the key players in the flow — and how to read what happened step by step in the app and on the explorer — things start to make sense.

Let’s walk through it together.


From one tap to on-chain execution: what actually happens

When you tap “Swap” in the app, it feels like a single action. In reality, you’re launching a multi-layered process built on top of Ethereum’s account abstraction (ERC-4337). Your transaction doesn’t go straight to the blockchain as with a normal wallet. Instead, it takes a detour:

  1. We build the route. We ask the routing engine (like 1inch) to find the best path for your swap, and simulate it to ensure it works. We estimate gas, validate that you have the tokens, and package the instructions into a special format: a UserOperation.

  2. A bundler steps in. This is an off-chain actor responsible for submitting UserOperations to the blockchain. It checks your op, makes sure it’s valid, and prepays the gas for you (it gets reimbursed later).

  3. Your UserOp enters the blockchain via the EntryPoint smart contract. Think of EntryPoint as the one gate all SCW transactions pass through. EntryPoint runs final checks, and if everything looks good…

  4. EntryPoint tells your Smart Contract Wallet (SCW) to execute the swap. Your SCW calls the router (e.g., 1inch), the router calls the pools, tokens move, and the output lands back in your wallet.

So to sum up: you tap swap → we simulate → bundler submits → EntryPoint validates → your SCW executes.


Let’s look at a real example

Now that we understand the high-level flow, let’s look at how this plays out in a real swap: first in the app, then on-chain:

Here’s what we see:

  • We swapped 1 USDC for 0.765 KTA.

  • The swap was executed on Base (note the Base icon on the coin symbols).

  • We paid:

    • $0.03 gas (in ETH)

    • 0.22% swap fee to goodcryptoX

    • 0.05% router fee to 1inch

  • The route was simple: 100% through a Uniswap v4 pool.

  • Bundler: Alchemy (see Step 2 above for recap)

  • Explorer links appear if the transaction had reached the blockchain and was recorded in the block (even if it fails)

So far, so good. Next, let’s click the BaseScan link to see what this transaction looks like on-chain:

Note on explorer links: In the latest app versions, explorer links already open your AA Transaction (UserOp). If that’s what you see (the "From" field shows your wallet address), you can skip directly to Step 5 – AA Transaction details page. The earlier steps only apply if your link points to the outer bundler transaction (where "From" is NOT your wallet). It's still a useful read, though, to better understand how SCW trasnactions work

From: this isn’t your wallet — it’s Alchemy’s bundler. That’s expected, since the bundler submitted the transaction.

To: EntryPoint (v0.6.0). Again, expected — all SCW transactions enter through here.

Internal Transactions: shows flows of native tokens (ETH on Base) within the transaction. Here's what we see:

  • Our wallet (…0A5) sent ETH to EntryPoint for the gas fee.

  • EntryPoint reimbursed the bundler with the actual gas cost (since the bundler prepaid gas on your behalf; see Step 2 above). Any leftover ETH remained in EntryPoint as your deposit for future transactions.

ERC-20 Transfers: shows the actual token movements:

Our wallet didn’t send USDC directly. Instead, the USDC token contract (…2A8) processed and dispatched the transfers. This is normal: on EVM chains, token transfers are handled by the token contract itself after receiving an instruction from your smart contract wallet.

  1. The USDC contract split our 1 USDC into three transfers:

    • 0.0022 USDC to our protocol’s fee wallet (…608A)

    • 0.0005 USDC to 1inch’s fee wallet (…1DE5)

    • The remaining 0.9973 USDC to the Uniswap v4 router (…Universal Router)

  2. The Uniswap v4 router passed it to the Uniswap v4 Pool Manager (single contract handling all v4 pools).

  3. The Pool Manager executed the swap: USDC in → KTA out.

  4. The KTA was routed back through 1inch’s Aggregation Router, which forwarded it to our wallet (…0A5).


🧩 How to decode a failed SCW transaction

Now that we understand how smart-contract-wallet (SCW) swaps work — and we’ve walked through a successful trade — let’s use the same tools to decipher a failed one.

We’ll use another real case: an ETH → token swap on Ethereum that failed inside EntryPoint contract because there wasn’t enough ETH to cover both the swap and the gas fee.

Ok, so you see "Error" as your swap status in the app or get a push notification that your swap failed. What do you do?


Step 1 — Check the order details in goodcryptoX

Here is what you see in this case:

Using the framework we've developed earlier, you quickly notice:

  • The swap status is Error (failed?)

  • No error message is shown (that's unusual)

  • There is gas fee (reached blockchain?)

  • There is route shown (simulation went ok?)

  • There are links to blockchain explorers (I can check the tx on the blockchain!).

Let's check your intuition:

  • The Error status means the swap failed

  • There should be both a human-readable error message (translated from raw) and the raw one. Absent error message definitely means something unusual happened

  • Gas fee indeed means that the transaction had reached the blockchain and some on-chain activity had happened (that consumed gas)

  • Route confirms that the transaction simulation passed and resulted in a clear path to execution

  • Explorer links confirm the transaction reached the blockchain — even if it failed. We should definitely open one of them and investigate further


Step 2 – Open the transaction in the blockchain explorer

Note on explorer links: In the latest app versions, explorer links already open your AA Transaction (UserOp). If that’s what you see (the "From" field shows your wallet address), you can skip directly to Step 5 – AA Transaction details page. The earlier steps only apply if your link points to the outer bundler transaction (where "From" is NOT your wallet). It's still a useful read, though, to better understand how SCW trasnactions work

You tap the Etherscan link to see what happened:

At first glance, things get even more confusing:

  • The status says ✅ Success — wait, what?!

  • But we already know the swap didn’t go through

  • Under the “To” field (EntryPoint), there’s a small yellow message:

    Although one or more errors occurred [execution reverted] Contract Execution Completed

So what's actually going on here?

Remember the SCW transaction flow we covered earlier:

  • the bundler wraps your swap into a UserOperation (a data package with your swap logic)

  • then sends it to the EntryPoint smart contract

  • EntryPoint validates it (checking your balance, signature, and nonce)

  • if everything checks out, it executes your intent — calling routers, pools, and moving tokens.

From the blockchain’s perspective, though, this whole thing just looks like "bundler sends data to EntryPoint".

In SCW terms, this step is called the outer transaction.

And that transaction did succeed: the data was delivered, and EntryPoint began running its internal logic. Hence the ✅ Success at the top.


But the explorer, being polite, still lets you know that something failed inside EntryPoint with that little yellow note. For the explorer, that internal failure isn’t enough to mark the transaction as failed.

Now, another details jumps out on the Overview tab:

  • About $6 worth of ETH was sent from your wallet to EntryPoint (the gas prefund).

  • Only $2.3 worth of ETH was reimbursed to the bundler.

  • And the transaction fee shown at the top is lower still — about $2.15.

At first glance, these numbers don’t seem to add up. Let’s unpack that first before continuing with the investigation


Step 3 – Understanding the gas discrepancy

Here’s the breakdown:

  • SCW → EntryPoint (~$6): This is the gas prefund. EntryPoint always collects more than needed to make sure your UserOp can run.

  • EntryPoint → Bundler (~$2.3): This is the actual gas reimbursement. It’s the real amount you paid for this failed attempt.

  • Transaction Fee (~$2.15): This is what the bundler spent to send your UserOp to EntryPoint. It’s lower because EntryPoint itself used extra gas while validating and reimbursing the bundler — that extra cost was charged to you.

Rule of thumb:

👉 Your true gas cost is always the EntryPoint ➜ Bundler reimbursement (not the “Transaction Fee” shown at the top)

And the difference between what you prefunded ($6) and what was reimbursed ($2.3) didn’t disappear. It remained in EntryPoint as your deposit, which will automatically be applied to your next transaction.


Step 4 – Check the AA Transactions tab

On the explorer, you see an AA Transactions tab (AA = Account Abstraction). This is where smart contract wallet activity lives, since SCWs run on Account Abstraction (ERC-4337).

Let’s switch to that tab from Overview:

Here you finally see our UserOperation listed as a separate entry inside the bundler’s outer transaction:

  • The "From" field now shows our wallet address, confirming this is our operation.

  • There’s a separate AA Txn Hash, different from the outer transaction hash. Why?

    • The outer Txn Hash belongs to the Bundler->EntryPoint transaction that contained your UserOp (and could have included multiple UserOps from various users).

    • The AA Txn Hash is the unique identifier for your UserOperation inside that bundle.

This is the key idea of bundling:

  • A bundler can package together many UserOps into one transaction.

  • Each UserOp gets its own AA Txn Hash, so it can be tracked separately inside the bundle.

  • In our case, because this is an older transaction (400+ days ago), SCWs were still rare and the bundle contained only our UserOp — that’s why the tab shows “AA Transactions (1).” In newer transactions, you’ll often see multiple UserOps batched together in one bundle.

In this view, you'll also notice a (!) icon next to your AA Txn Hash — confirmation that your swap didn’t execute.

The next step is to click the AA Txn Hash. That opens the dedicated UserOperation page, where you’ll see the full details of our swap attempt — fee, transfers, and where it failed.


Step 5 – Open the AA Transaction details page

Clicking the AA Txn Hash takes you to the dedicated detail page for your UserOperation:

Here you can finally see our actual swap attempt laid out clearly:

  • Status: x Fail (no ambiguity this time)

  • From: your smart contract wallet address

  • AA Transaction Fee: ~0.00231 ETH ($2.31). This is the real gas cost you paid — the reimbursement sent to the bundler.

  • Internal transaction: one transfer of ~0.00145 ETH ($6.36) from your SCW to EntryPoint (gas prefund). No other transfers occurred, which confirms the swap itself never executed.

  • Bundle Txn Hash: shown as well, linking back to the outer bundler transaction.

This page finally matches your intuition: this is the real transaction — the UserOperation that represented your swap attempt.

That almost concludes our investigation. But since we’ve come this far, let’s also click on Internal Txns.


Step 6 – Check the Internal Transactions tab

Switch to the Internal Txns tab inside the AA Transaction view:

Here you see the step-by-step actions that EntryPoint tried to perform on your behalf:

  1. ✅ Transfer from your SCW → EntryPoint (~0.00145 ETH, ~$6.36) = gas prefund. This succeeded.

  2. ❌ Execute from your SCW → Uniswap Universal Router (~0.002 ETH) = attempted swap. This failed.

This breakdown explains the failure:

  • You successfully sent ETH to EntryPoint as gas prefund.

  • But when EntryPoint tried to forward ETH to Uniswap for the swap, the attempt failed.

For the most detailed breakdown, open the Logs tab.


Step 7 – Inspect the Logs tab

Click on Logs (3):

Here you’ll find three key events:

  • Deposited → confirms that your gas prefund was received by EntryPoint.

  • BeforeExecution → shows that EntryPoint began processing your UserOperation.

  • UserOperationEvent success: False — the canonical on-chain record that your UserOp failed.


What actually happened (putting it all together)

This type of failure is specific to swaps with SCWs on EVMs where the input is the native token (ETH, BNB, MATIC…).

  • The gap: neither the bundler nor the EntryPoint check whether you have enough native token to cover both the gas prefund and the swap together. They only check these separately — “enough for gas?” and “enough for swap?”. That’s why the simulation passed.

  • We've built a failsafe in the app for these cases, warned you in the interface that gas might be insufficient. But since the simulation looked fine, you could still click through.

  • Once you confirmed, the bundler submitted your UserOperation to EntryPoint.

  • EntryPoint pulled in about $6 worth of ETH as prefund.

  • When it tried to execute the swap, there wasn’t enough ETH left to cover both the swap and the prefund at the same time.

  • The swap call reverted inside EntryPoint.

  • You still paid ~$2.3 in gas (the reimbursement to the bundler).

  • The unused ~$3.7 remained in EntryPoint as your deposit, to be used automatically on your next transaction.

Last updated