[ Web Proxy ]
URL:
Viewing: https://docs.cloud.google.com/blockchain-rpc/docs/quickstart [Back]  [Original]

Quickstart: Blockchain RPC  |  Google Cloud Documentation Skip to main content
Google Cloud Documentation [Google Cloud Documentation]
Send feedback

Quickstart: Blockchain RPC Stay organized with collections Save and categorize content based on your preferences.

Preview

This product is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the Service Specific Terms. Pre-GA products are available "as is" and might have limited support. For more information, see the launch stage descriptions.

Required roles

To get the permissions that you need to view API keys, ask your administrator to grant you the API Key Viewer (roles/serviceusage.apiKeysViewer) IAM role on your project. For more information about granting roles, see Manage access to projects, folders, and organizations.

You might also be able to get the required permissions through custom roles or other predefined roles.

Using the RPC endpoint

  1. In the Google Cloud console, go to the Blockchain RPC page.

    Go Blockchain RPC

  2. From the console, copy the JSON-RPC endpoint that matches the network and location combination you need.

    Blockchain RPC quickstart [Blockchain RPC quickstart]

  3. Now you can begin making requests. A full list of all the RPC methods available are listed in the RPC API reference documentation. Our example request calls the eth_blockNumber method.

curl -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method":
  "eth_blockNumber",
  "params": []}' \
JSON_RPC_ENDPOINT

Where:

After executing this curl request, you should see a response like:

{"jsonrpc":"2.0","id":1,"result":"0x13acb8d"}

Using WebSocket subscriptions

WebSocket support is also enabled for Blockchain RPC endpoints. This example uses the wscat open source project.

  1. In the Google Cloud console, go to the Blockchain RPC page.

    Go Blockchain RPC

  2. From the console, copy the WebSocket endpoint that matches the network and location combination you need.

    Blockchain RPC quickstart [Blockchain RPC quickstart]

  3. Now you can begin making requests.

wscat -c WS_ENDPOINT

Where:

Subscribe to new block headers:

{"id":1,"jsonrpc":"2.0","method":"eth_subscribe","params":["newHeads"]}

You'll start receiving messages for each new block header.

Send feedback

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-08-12 UTC.

Need to tell us more? [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-08-12 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page