aboutsummaryrefslogtreecommitdiffstats
path: root/eth/api.go
diff options
context:
space:
mode:
authorHackyMiner <hackyminer@gmail.com>2018-09-30 04:07:02 +0800
committerFelix Lange <fjl@users.noreply.github.com>2018-09-30 04:07:02 +0800
commit107f556b2d9811ea2d64c065531dcae33997fcb7 (patch)
treef8d1bd899336caf38fb4cb546e22312347bd7008 /eth/api.go
parent44eb69561a32c1b1e5345b5872e7de69fff936c2 (diff)
downloadgo-tangerine-107f556b2d9811ea2d64c065531dcae33997fcb7.tar
go-tangerine-107f556b2d9811ea2d64c065531dcae33997fcb7.tar.gz
go-tangerine-107f556b2d9811ea2d64c065531dcae33997fcb7.tar.bz2
go-tangerine-107f556b2d9811ea2d64c065531dcae33997fcb7.tar.lz
go-tangerine-107f556b2d9811ea2d64c065531dcae33997fcb7.tar.xz
go-tangerine-107f556b2d9811ea2d64c065531dcae33997fcb7.tar.zst
go-tangerine-107f556b2d9811ea2d64c065531dcae33997fcb7.zip
internal/ethapi: add eth_chainId method (#17617)
This implements EIP-695.
Diffstat (limited to 'eth/api.go')
-rw-r--r--eth/api.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/eth/api.go b/eth/api.go
index 708f75a78..3ec3afb81 100644
--- a/eth/api.go
+++ b/eth/api.go
@@ -67,6 +67,15 @@ func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64 {
return hexutil.Uint64(api.e.Miner().HashRate())
}
+// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
+func (api *PublicEthereumAPI) ChainId() hexutil.Uint64 {
+ chainID := new(big.Int)
+ if config := api.e.chainConfig; config.IsEIP155(api.e.blockchain.CurrentBlock().Number()) {
+ chainID = config.ChainID
+ }
+ return (hexutil.Uint64)(chainID.Uint64())
+}
+
// PublicMinerAPI provides an API to control the miner.
// It offers only methods that operate on data that pose no security risk when it is publicly accessible.
type PublicMinerAPI struct {