Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misidentifying non-ERC-20 contracts as ERC-20 #9901

Open
lyfsn opened this issue Apr 17, 2024 · 1 comment
Open

Misidentifying non-ERC-20 contracts as ERC-20 #9901

lyfsn opened this issue Apr 17, 2024 · 1 comment
Labels

Comments

@lyfsn
Copy link

lyfsn commented Apr 17, 2024

Description

Due to this PR:
https://github.com/blockscout/blockscout/pull/7653/files#diff-f361e4f9074748318960424dc947ccec166d7630df1322526105b22749b7ac37R179

Blockscout will identify any contract that emits this event:

event Deposit(address indexed user, uint256 amount);

Blockscout will incorrectly identify a contract as ERC-20, although it is actually not an ERC-20 contract. This will result in many erroneous queries to the node, such as balanceOf requests.

This whole contract source code example:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/access/Ownable.sol";

contract DepositETH is Ownable {
    event Deposit(address indexed user, uint256 amount);
    mapping(address => uint) public totalDeposits;
    uint256 public totalUniqueDepositors;

    constructor(address initialOwner) Ownable(initialOwner) {}

    receive() external payable {
        uint256 oldValue = totalDeposits[msg.sender];
        if (oldValue == 0) {
            totalUniqueDepositors++;
        }
        totalDeposits[msg.sender] += msg.value;
        emit Deposit(msg.sender, msg.value);
    }

    function getTotalDepositOf(address user) external view returns (uint256) {
        return totalDeposits[user];
    }

    function getTotalDepositFrom(
        address[] calldata users
    ) external view returns (uint256[] memory) {
        uint256[] memory result = new uint256[](users.length);
        for (uint256 i = 0; i < users.length; i++) {
            result[i] = totalDeposits[users[i]];
        }
        return result;
    }

    function withdraw() external onlyOwner {
        payable(owner()).transfer(address(this).balance);
    }
}
  1. Deploy it to a network;
  2. Send any amount to this contract.

You will get an "Unnamed token":

Screenshot 2024-04-17 at 15 24 35

Type of the installation

Docker-compose

Type of the JSON RPC archive node

Geth

Type of the chain

No response

Link to the page

No response

Steps to reproduce

No response

Backend version

v6.3.0-beta

Frontend version

No response

Elixir & Erlang/OTP versions

Elixir

Operating system

No response

Additional information

No response

@lyfsn lyfsn added the triage label Apr 17, 2024
@abdouferraq
Copy link

Screenshot_2024-05-25-04-44-14-976_com binance dev
Screenshot_2024-05-25-04-44-08-134_com binance dev
Screenshot_2024-05-25-04-43-33-663_com binance dev
Screenshot_2024-05-25-04-42-43-798_com binance dev
Screenshot_2024-05-25-04-42-38-046_com binance dev
Screenshot_2024-05-25-04-27-00-530_com blockabc cctip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants