Skip to content

Commit 341f451

Browse files
authored
graphql: add support for retrieving the chain id (#21451)
1 parent d13b8e5 commit 341f451

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

graphql/graphql.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,10 @@ func (r *Resolver) ProtocolVersion(ctx context.Context) (int32, error) {
10441044
return int32(r.backend.ProtocolVersion()), nil
10451045
}
10461046

1047+
func (r *Resolver) ChainID(ctx context.Context) (hexutil.Big, error) {
1048+
return hexutil.Big(*r.backend.ChainConfig().ChainID), nil
1049+
}
1050+
10471051
// SyncState represents the synchronisation status returned from the `syncing` accessor.
10481052
type SyncState struct {
10491053
progress ethereum.SyncProgress

graphql/schema.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ const schema string = `
314314
protocolVersion: Int!
315315
# Syncing returns information on the current synchronisation state.
316316
syncing: SyncState
317+
# ChainID returns the current chain ID for transaction replay protection.
318+
chainID: BigInt!
317319
}
318320
319321
type Mutation {

0 commit comments

Comments
 (0)