1

I was studying the uniswap V2 smart contract, and I saw that in the constructor part, using assembly, the value of the chainId was set in a variable.

    constructor() public {
        uint chainId;
        assembly {
            chainId := chainid
        }
        DOMAIN_SEPARATOR = keccak256(
            abi.encode(
                keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
                keccak256(bytes(name)),
                keccak256(bytes('1')),
                chainId,
                address(this)
            )
        );
    } 

Is it possible to create a blockchain whose chainId will encounter overflow when the constructor is executed?

Is there a law to choose chainId for new blockchains?

2

1 Answer 1

1

ChainId has a size of 256 bits, meaning there can not be a number that is larger than that in blockchain saved in a single variable. So to answer your question, no there can not be any overflow.

The following article might help: https://eips.ethereum.org/EIPS/eip-1344

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.