Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.

Commit ddaff64

Browse files
committed
problem: implement eth_chainId json RPC method
solution: do it - update changelog fixes #335
1 parent a8a0b79 commit ddaff64

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Rolling builds for the master branch may be found at [builds.etcdevteam.com](bui
2323

2424
#### Added
2525
- JSON-RPC: `debug_traceTransaction` method
26+
- JSON-RPC: `eth_chainId` method; returns configured Ethereum EIP-155 chain id for signing protected txs
2627
- P2P: improve peer discovery by allowing "good-will" for peers with unknown HF blocks
2728

2829
## [3.5.86] - 2017-07-19 - db60074

eth/api.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,15 @@ func (s *PublicEthereumAPI) Syncing() (interface{}, error) {
176176
}, nil
177177
}
178178

179+
// ChainId returns the chain-configured value for EIP-155 chain id, used in signing protected txs.
180+
// If EIP-155 is not configured it will return 0.
181+
// Number will be returned as a string in hexadecimal format.
182+
// 61 - Mainnet $((0x3d))
183+
// 62 - Morden $((0x3e))
184+
func (s *PublicEthereumAPI) ChainId() *big.Int {
185+
return s.e.chainConfig.GetChainID()
186+
}
187+
179188
// PublicMinerAPI provides an API to control the miner.
180189
// It offers only methods that operate on data that pose no security risk when it is publicly accessible.
181190
type PublicMinerAPI struct {

internal/web3ext/web3ext.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,11 @@ web3._extend({
340340
call: 'eth_submitTransaction',
341341
params: 1,
342342
inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
343+
}),
344+
new web3._extend.Method({
345+
name: 'chainId',
346+
call: 'eth_chainId',
347+
params: 0
343348
})
344349
],
345350
properties:

0 commit comments

Comments
 (0)