Recognising a wrap or unwrap
The one protocol action Forensia names outright, and why it refuses to name anything it cannot match exactly.
#Plain languageIn plain terms
Most transactions are calls to contracts, and a call's meaning depends on the contract. Naming what a call did is risky. A function called deposit can do anything its author wrote.
Forensia takes the cautious route. It names an action only when it can check the request and the result against each other exactly. Today that covers one case: wrapping ETH into WETH, or unwrapping it, by calling the official WETH contract on Ethereum directly.
Wrapping swaps ETH for a token that represents it one-for-one, so it can be used where only tokens are accepted. It is a change of form, not a trade.
#How it worksHow it works
- Confirm the transaction is on Ethereum and is sent straight to the WETH contract.
- Confirm it succeeded and its receipt is bound to it.
- Confirm the transaction format and the block's rule set are ones this reading was reviewed for.
- Read the call data to see whether it asks to wrap or unwrap, and how much.
- Find the matching event in the receipt.
- Name the action only if the account and the amount agree exactly on both sides.
#Technical detailThe exact rules
The contract is WETH9 at 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 on Ethereum mainnet.
| Action | Call data | Amount comes from | Event required |
|---|---|---|---|
| Wrap | Empty, or selector 0xd0e30db0 | The ETH sent with the transaction | Deposit(address,uint256) |
| Unwrap | Selector 0x2e1a7d4d and one 32-byte word | That word. No ETH may be attached. | Withdrawal(address,uint256) |
There must be exactly one such event from the WETH contract in the receipt. Its account must equal the transaction's sender and its amount must equal the requested amount to the last unit. A second wrap or unwrap event makes the reading ambiguous, and nothing is claimed. A receipt with more than 256 logs is not read.
The action is also gated on context. The transaction and the receipt must both report the same type, from 0 to 4, and the block must match the pinned Ethereum fork schedule. If the call looks like a wrap or unwrap but that context is missing or unsupported, the result carries a warning beginning "Wrapping explanation withheld" and the captured activity is still shown.
The result is tagged with the adapter name ethereum-weth9-direct.v2 and carries the three evidence records it rests on: the transaction, the receipt and the block. Results saved under the earlier ethereum-weth9-direct.v1, which did not record the transaction format, keep that tag and are not upgraded.
#LimitsWhat it does not tell you
- WETH reached through a router or another contract is not named. Only a direct call is.
- Swaps, loans, staking and every other protocol action are outside this adapter.
- Wrapped tokens on other networks are not covered.
- A failed transaction is never named as a wrap or unwrap.