aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eth/api.go9
-rw-r--r--internal/web3ext/web3ext.go5
2 files changed, 14 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 {
diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go
index f4eb47a12..bf4b7808f 100644
--- a/internal/web3ext/web3ext.go
+++ b/internal/web3ext/web3ext.go
@@ -434,6 +434,11 @@ web3._extend({
property: 'eth',
methods: [
new web3._extend.Method({
+ name: 'chainId',
+ call: 'eth_chainId',
+ params: 0
+ }),
+ new web3._extend.Method({
name: 'sign',
call: 'eth_sign',
params: 2,