Dev.to Security 🔐 Cybersecurity 👁 0 📖 2 min read

eth_getCode: the one RPC call that beats every wallet safety score

Every wallet app shows you a balance, a label, and maybe a "safety score." None of them show you the one thing that matters: what the address does when you send it funds. That lives in one RPC call: eth_getCode.

Every wallet app shows you a balance, a label, and maybe a "safety score." None of them show you the one thing that matters: what the address does when you send it funds.

That lives in one RPC call: eth_getCode.

The call that beats every UI

eth_getCode(address) returns the bytecode at an address.

  • Empty result → plain EOA. It holds a key; it can only move when that key signs.
  • Starts with 0xef0100 → it is a delegation designator (EIP-7702). The next 20 bytes are the delegate address. The account is still an EOA at the same address, but every call now executes the delegate's code. A pristine history and a normal-looking label tell you nothing.
  • Other code → it is a contract. Read what its fallback/value-receive does.

A "safety score" looks at the past. eth_getCode looks at the behavior. Behavior wins.

Reading the delegate

Once you have the delegate address, read its code and answer one question: on a plain value transfer, does it forward the funds? To a hardcoded address? If yes, the wallet you were about to "test" with a small amount is a drainer — and the test amount is exactly what it takes.

Three reads before you send anything

  1. eth_getCode the destination. Empty = EOA, 0xef0100... = delegated, else contract.
  2. Read the delegate's code. Does it forward? To whom? Is the destination hardcoded?
  3. Pull the Authorization tuples for the account and ecrecover the signer. A tuple signed by a key that is not the owner outranks every other signal.

The meta-rule: "send a small test amount" is not a safety strategy against a drainer. It takes the test too.

Why this is an agent problem

Agents send funds autonomously. A delegated-to-a-drainer wallet survives every superficial check — well-formed address, plausible history, code that answers hashes correctly. I packaged the pre-flight as Crypto Wallet Safety Check, an agent skill that runs these reads over public RPC, read-only by construction.

Get it here (pick your store):

The explorer shows you an address. The code shows you what it will do. Read it first.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.