EIPs Explained

EIP-107 · Stagnant · Interface · 2016-06-05

EIP-107: safe "eth_sendTransaction" authorization via html popup

A 2016 proposal for nodes to serve an HTML popup so ordinary websites could request eth_sendTransaction with user confirmation, instead of enabling CORS and trusting the dapp.

What problem does it solve?

In 2016, a dapp in a normal browser could only reach your local Ethereum node's RPC if you enabled CORS for its domain. Once you did, the site could call eth_sendTransaction from any unlocked account with no prompt at all. Users had to either trust the site completely or copy transactions by hand into Mist or the node's console.

EIP-107 proposes a way for websites to use the node safely: read-only calls just work, and every transaction needs an explicit click from the user.

How it works

The node serves one self-contained page at <node url>/authorization.html. Because the page comes from the node's own origin, browser same-origin rules protect it. The dapp uses the page in two ways:

  1. Invisible iframe. The dapp embeds it and sends read-only RPC calls through window.postMessage. The iframe refuses any call that needs an unlocked key, so a hidden frame can't trick users into confirming.
  2. Popup window. For eth_sendTransaction, the dapp opens the same URL in a new window. It shows the sender, recipient, amount and gas cost, and only forwards the call if the user confirms. eth_sign is deliberately not allowed, because the popup cannot show its meaning safely.

Message protocol:

  • The frame or window first posts the string "ready".
  • The dapp sends { id, payload }, where payload is a normal JSON-RPC object.
  • The reply is { id, result, error }, and error.type === "cancel" means the user rejected.
  • from, gas and gasPrice must be set so the popup can display them.

If the account is locked and the node exposes the personal API, the popup can ask for the password and unlock it briefly (3 seconds in the reference page).

Sample code

Dapp side, sending a transaction through the popup:

const NODE = "http://localhost:8545";
const popup = window.open(`${NODE}/authorization.html`, "eth-auth", "width=420,height=520")!;

window.addEventListener("message", (ev) => {
  if (ev.origin !== NODE) return;
  if (ev.data === "ready") {
    popup.postMessage({
      id: 1,
      payload: {
        jsonrpc: "2.0", id: 1, method: "eth_sendTransaction",
        params: [{ from: "0x…", to: "0x…", value: "0x2386f26fc10000",
                   gas: "0x5208", gasPrice: "0x4a817c800" }],
      },
    }, NODE);
  } else if (ev.data.id === 1) {
    if (ev.data.error?.type === "cancel") console.log("user rejected");
    else console.log("tx hash", ev.data.result);
  }
});

Things to know

  • This proposal is Stagnant and was never standardized or widely deployed.
  • The ecosystem went a different way. Wallets such as browser extensions inject a provider (EIP-1193), ask the user to connect accounts (EIP-1102, EIP-2255), and show their own confirmation screens. Today the node usually never sees the user's keys at all.
  • The design assumes accounts unlocked inside the node, which is now discouraged.
  • It remains a useful historical record of why "the dapp must never sign without the user" became a core wallet principle.

#json-rpc #wallet #dapp #authorization #interface

Details

Authors
Ronan Sandford (@wighawag)
Status
Stagnant
Type
Standards Track / Interface
Created
2016-06-05

Machine-readable: Markdown · JSON