Solidity type information

frenchkebab·2023년 5월 16일
0
post-thumbnail
    function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) { // here
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

ERC20 코드를 분석하다가, type() 에 대해서 항상 궁금해만 하다가 이번에 공식 문서에서 찾아보았다.

https://docs.soliditylang.org/en/v0.8.17/units-and-global-variables.html#meta-type

The expression type(X) can be used to retrieve information about the type X. Currently, there is limited support for this feature (X can be either a contract or an integer type) but it might be expanded in the future.

profile
Blockchain Dev Journey

0개의 댓글