Open oberstet opened 4 years ago
It is a bug in Ganache that is tricky to fix due to backcompat reasons. We'll be changing this behavior in the next major version of ganache-core
(https://github.com/trufflesuite/ganache-core/issues/451)
Note that chain ID !== network id (net_version). The bug is actually different than you have discovered, as the eth_chainId
RPC actually returns 1337
right now, but 1
for the chainid
opcode in the EVM.
Ah, ok, thanks for confirming!
Looking forward, as I am working on some 2-layer stuff and getting all the EIP712 bits working together (for which I need the chain ID to prevent replay attacks) is tricky .. some stuff required is still in the move/new/buggy ;)
I am using Ganache v6.9.1 (from docker
trufflesuite/ganache-cli:v6.9.1
) with--networkId=5777
and want to read the chain ID from within solidity using:source: https://github.com/crossbario/xbr-protocol/issues/51#issuecomment-590196349
The returned chain ID however is not 5777, but always 1.
Is this a know bug? Am I doing sth wrong?
I am using truffle 5.1.14 and pragma solidity ^0.5.12; in my contracts, as the CHAINID opcode was only intruduced in v0.5.12 https://solidity.readthedocs.io/en/v0.5.12/assembly.html#opcodes