Since v0.5.12, Solidity provides a CHAINID OPCODE in assembly:
function getChainID() external view returns (uint256) {
uint256 id;
assembly {
id := chainid()
}
return id;
}
Is there an equivalent in Vyper?
Since v0.5.12, Solidity provides a CHAINID OPCODE in assembly:
function getChainID() external view returns (uint256) {
uint256 id;
assembly {
id := chainid()
}
return id;
}
Is there an equivalent in Vyper?
Since Vyper v0.1.0-beta15 the chain ID is available through the chain.id environment variable:
Here is a minimal example to verify the behavior:
@public
@constant
def foo() -> uint256:
return chain.id
Note that this is only possible if the compiler is set to target the Istanbul EVM ruleset or later.