Skip to content

CheckContract for token contracts #162

@abhi3700

Description

@abhi3700

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");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions