EIP-2566 Human-readable contract execution parameters (Human Readable Parameters for Contract Function Execution)

No call decision · Security & privacy · EIP status Stagnant · created 2020-03-23

A proposal to add a new RPC method, eth_sendTransactionToContractFunction, which passes the function ABI along with the call so that the wallet can show the called function name and argument values in human-readable form in the confirmation screen before signing a transaction.

Why it is needed

Today, the data field in the eth_sendTransaction that a dapp sends to a wallet is a byte string formed by concatenating the first 4 bytes of the keccak256 hash of the function signature with the ABI-encoded arguments. Since keccak256 cannot be inverted, the original function name cannot be recovered from these 4 bytes, and the argument values that follow carry no type information, so they cannot be interpreted either. As a result, the wallet can only show unknown hex data in the confirmation screen, and the user has no way of knowing which function is actually being called with which values. Exploiting this gap, a malicious dapp could secretly change just the recipient address in a function like transfer(address,uint256) to intercept tokens, and the user would have a hard time noticing. Aragon Radspec requires special comments to be added to the contract in advance, so it is not general purpose, and EIP-1138 allowed the dapp itself to construct the display message, which carried a risk of manipulation.

What changes

Today

After EIP-2566

Who is affected

In depth

Proposed RPC method

eth_sendTransactionToContractFunction accepts the same parameters as the existing eth_sendTransaction (from, to, gas, gasPrice, value, data, nonce) plus one additional abi field. The abi is a single element of the contract ABI corresponding to the function being called, including name, inputs, outputs, stateMutability, and type. The return value is also the same 32-byte transaction hash as eth_sendTransaction, and a zero hash is returned if the transaction is not yet available.

Why the data field is unreadable

The data field in eth_sendTransaction is a value formed by concatenating the first 4 bytes of the keccak256 digest of the function signature with the ABI-encoded arguments. Since keccak256 cannot be inverted, there is no way to recover the original function signature from these 4 bytes, and the type information for the argument bytes that follow exists only in the signature preimage, so they cannot be interpreted as is. From this data alone, the wallet has no way of knowing which function is being called with which values.

How to reconstruct data using the abi

Given the abi, the wallet can reconstruct the function signature string from the name and inputs types, compute the first 4 bytes of its keccak256 hash, and compare it against the first 4 bytes of data. A match serves as additional verification that the supplied abi matches the actual function being called, and afterward the type information in inputs can be used to decode the remaining bytes of data and display each argument value in human-readable form.

Difference from existing approaches

Aragon Radspec requires human-readable comments to be added to the contract code in advance, and may require IPFS integration, so it cannot be used with contracts that lack such comments. EIP-1138 allowed the dapp to directly generate the message shown to the user, which carried a security problem where an untrusted dapp could manipulate the message. This proposal has the wallet itself reconstruct the message based on the contract's actual ABI, so the dapp cannot arbitrarily craft the displayed content.

Backward compatibility

Rather than modifying the existing eth_sendTransaction, the approach taken was to add a new method. Adding an abi argument to eth_sendTransaction was also considered but rejected because it would break all existing code that already uses that method. It is noted that eth_signTypedData from EIP-712 is cited as a precedent for adding a new RPC method.

Security limitations

This proposal lets the user check the contract address, function name, and argument values, but it does not guarantee that the function behaves exactly as shown. A malicious contract could mimic the name and types of something like transfer(address,uint256) while doing something else entirely, and preventing this would require inspecting the contract code itself. This EIP states explicitly that it only addresses transparency of data interpretation, not the question of trust in the contract itself.

Current status

This EIP is in Stagnant status and is no longer being actively discussed. The specification is also not a finalized spec, for example the default value of gasPrice in the spec is still left as 'To-Be-Determined,' and neither the original text nor the provided call records contain any decision on actual implementation or inclusion in a fork.

Original EIP · ← EIPs