web3j
web3j copied to clipboard
Add support for determining network version automatically
The net_version JSON-RPC call provides information on the network the Ethereum client is connected to.
This information could be cached in web3j's RawTransactionManager, following the first transaction call, enabling web3j to automatically support EIP155 in full.
Do I understand it correctly that after this change this code in the RawTransactionManager
:
if (chainId > ChainId.NONE) {
...
}
will be replaced with something like:
if (getChainId() > ChainId.NONE) {
...
}
where getChainId()
is:
private byte getChainId() {
// Return cached chainId or return a call "net_version"
}
Chain id != net version ...
The only way to get the correct chain id, is to get the latest block and analyze the signature on the (first) transaction. If EIP-155 is not enabled on your private network, then chain id can be null, and thus different from the network version.
There is a JSON RPC endpoint eth_chainId, https://github.com/ethereum/EIPs/blob/master/EIPS/eip-695.md
It's implemented by the major clients Geth, Classic, Parity, Besu, Quorum and in Ganache...
Happy to submit a PR
Hi All, is this issue closed and changes made?