Skip to content

chainid opcode returns an error #1494

Answered by achraf17
frank-lim-partior asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @frank-part ,
There are two solutions to fix the issue:

  1. when compiling your contract, use the --evm-version istanbul flag docs. You have the same config in remix under advanced configuration.
  2. upgrade the solidity version to ^0.8.0 and you can use block.chainid directly without assembly code.
function getChainId() public view returns (uint256) {
   return block.chainid;
}

You also need to ensure that you are running on the istanbul fork and that you have specified istanbulBlock in your genesis.

Replies: 1 comment 15 replies

Comment options

You must be logged in to vote
15 replies
@frank-lim-partior
Comment options

@antonydenyer
Comment options

@frank-lim-partior
Comment options

@antonydenyer
Comment options

@frank-lim-partior
Comment options

Answer selected by antonydenyer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #1490 on September 05, 2022 09:32.