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

CheckContract for token contracts #162

Open
abhi3700 opened this issue Jun 8, 2022 · 3 comments
Open

CheckContract for token contracts #162

abhi3700 opened this issue Jun 8, 2022 · 3 comments

Comments

@abhi3700
Copy link

abhi3700 commented Jun 8, 2022

Instead of this line, the check contract logic can be written by introducing a function like this:

/**
 * Check that the account is an already deployed non-destroyed contract.
 * See: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol#L12
 */
function _checkContract(address _account) private view {
    require(_account != address(0), "Account cannot be zero address");

    uint256 size;
    // solhint-disable-next-line no-inline-assembly
    assembly {
        size := extcodesize(_account)
    }
    require(size != 0, "Account code size cannot be zero");
}
@hacklili
Copy link

what

@abhi3700
Copy link
Author

this is to check whether the parsed contract address has some ERC20 code.

@ghost
Copy link

ghost commented Dec 31, 2023

this is not recommended because

  1. It blocks developers creating a pair before deploying a token contract ( some may find this useful )

  2. Every pair liquidity is dedicated so if the pair token isn't deployed or doesn't fulfill ERC20 standard core functionality wouldn't work including providing liquidity, etc. so it doesn't matter.

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

No branches or pull requests

2 participants