istanbul chainId opcode returns bad value
See original GitHub issueSteps to reproduce
- Start ganache-cli using the following command:
ganache-cli -l 8000000 -i 65535 -h 0.0.0.0 -k istanbul
- Compile/deploy the following contract:
contract ChainIdTest
{
function chainId()
public pure returns (uint256 id)
{
assembly { id := chainid() }
}
}
- 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:
- Created 4 years ago
- Reactions:5
- Comments:18 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just spent hours debugging this, extremely frustrating.
web3.eth.chainId() should give the same value as the chainId opcode
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”