Skip to content

Commit

Permalink
eth,internal: add eth_chainId method to PublicEthereumApi JSONRPC
Browse files Browse the repository at this point in the history
  • Loading branch information
whilei committed Aug 18, 2017
1 parent bf1e263 commit ee555bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ 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() *big.Int {
return api.e.chainConfig.ChainId
}

// 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 {
Expand Down
5 changes: 5 additions & 0 deletions internal/web3ext/web3ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,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',
Expand Down

0 comments on commit ee555bc

Please sign in to comment.