ERC-681 implementation bug: Wrong value on ERC-20 token transactions #1549
Description
The bug
When parsing ERC-681 encoded URIs or QR Codes for ERC-20 token transactions, the uint256
parameter is parsed wrong.
MetaMask seems to assume the uint256
value is on main token unit, instead of atomic unit.
Example:
ethereum:0xdAC17F958D2ee523a2206206994597C13D831ec7/transfer?address=0x8e23ee67d1332ad560396262c48ffbb01f93d052&uint256=1500000
should be parsed to 1.5 USDT, but instead is parsed as 1.5 million USDT
In order to parse 1.5 USDT the URI needs to be constructed like:
ethereum:0xdAC17F958D2ee523a2206206994597C13D831ec7/transfer?address=0x8e23ee67d1332ad560396262c48ffbb01f93d052&uint256=1.5
Which not only doesn't match what's on the spec (https://github.com/ethereum/EIPs/blob/master/EIPS/eip-681.md)
Requesting payments in ERC #20 tokens involves a request to call the
transfer
function of the token contract with anaddress
and auint256
typed parameter, containing thebeneficiary address
and theamount in atomic units
, respectively.
but also makes no sense, since it's supposed to be a unsigned integer, not a decimal value.
To Reproduce
- Generate a ERC-20 token QR Code or payment URI (https://brunobar79.github.io/eip681-link-generator/)
- Parse it with MetaMask
Expected behavior
Token value parsed in atomic units
Smartphone (please complete the following information):
- Device: Galaxy S9
- OS: Android 10
- Version: 28