File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,15 @@ func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64 {
6767 return hexutil .Uint64 (api .e .Miner ().HashRate ())
6868}
6969
70+ // ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
71+ func (api * PublicEthereumAPI ) ChainId () hexutil.Uint64 {
72+ chainID := new (big.Int )
73+ if config := api .e .chainConfig ; config .IsEIP155 (api .e .blockchain .CurrentBlock ().Number ()) {
74+ chainID = config .ChainID
75+ }
76+ return (hexutil .Uint64 )(chainID .Uint64 ())
77+ }
78+
7079// PublicMinerAPI provides an API to control the miner.
7180// It offers only methods that operate on data that pose no security risk when it is publicly accessible.
7281type PublicMinerAPI struct {
Original file line number Diff line number Diff line change @@ -433,6 +433,11 @@ const Eth_JS = `
433433web3._extend({
434434 property: 'eth',
435435 methods: [
436+ new web3._extend.Method({
437+ name: 'chainId',
438+ call: 'eth_chainId',
439+ params: 0
440+ }),
436441 new web3._extend.Method({
437442 name: 'sign',
438443 call: 'eth_sign',
You can’t perform that action at this time.
0 commit comments