question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

istanbul chainId opcode returns bad value

See original GitHub issue

Steps to reproduce

  1. Start ganache-cli using the following command:
ganache-cli -l 8000000 -i 65535 -h 0.0.0.0 -k istanbul
  1. Compile/deploy the following contract:
contract ChainIdTest
{
	function chainId()
	public pure returns (uint256 id)
	{
		assembly { id := chainid() }
	}
}
  1. Call the chainId() function.

I expect the returned value to be the chainId passed using the -i flag and accessible using await web3.eth.net.getId(); … but I get a value of 1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

14reactions
dmihalcommented, Jan 30, 2020

Just spent hours debugging this, extremely frustrating.

web3.eth.chainId() should give the same value as the chainId opcode

7reactions
Amxxcommented, Dec 11, 2019

Also, while chainID and networkID are not strictly speaking the same thing, in the ETH community, the mainnet and the testnests (rinkey, ropsten, kovan, goerli) have this property that chainID = networkID.

My usage is to be able to verify meta-transaction signatures that target contracts deployed at the same address on multiple network. When running ganache-cli with option -i we assume that this will set both chainId and networkId so that the ganache behaves just like “one more eth testnet”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ethereum's Istanbul Fork — Technical Explanation - Medium
The new CHAINID opcode introduced at 0x46 pushes the 256-bit value of the current chain ID to the stack. It pops 0 arguments...
Read more >
Georgios Konstantopoulos on Twitter: "A teammate of mine & I ...
istanbul chainId opcode returns bad value · Issue #515 · trufflesuite/ganache. Steps to reproduce Start ganache-cli using the following command: ganache-cli ...
Read more >
Geth private network return error "invalid opcode
The selfbalance opcode was implemented in the Istanbul chain fork (source). You need to allow the fork in your genesis.json
Read more >
ethereum/solidity - Gitter
The "chainid" instruction is only available for Istanbul-compatible VMs (you ... for it to be live on mainnet before allowing devs to test...
Read more >
Experiencing an "invalid signature error" when trying to use ...
Turns out that the chainid OPCODE is not working correctly in Ganche (if you use their UI ... istanbul chainId opcode returns bad...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found