BlockOps
DashboardTutorialsAbout usTerms of service
  • Welcome to Blockops Docs
  • Blog
  • Page
  • Contact Us
  • Why use Blockops
  • Developer
    • Getting Started
      • How to create an account
    • Products
      • API Service
      • Mission Control
        • Appchain Deployment
        • Node Deployment
        • Parachain Deployment
        • Rollup Deployment
        • DVT Deployment
      • Telescope
      • Public Network Monitors
      • R2D2 (Our Intelligent Node AI Assitant)
      • Staking with Blockops
  • FAQs
  • NETWORKS
  • MISC
    • Support
    • Glossary
      • Application
      • Network
      • Node
      • Project
Powered by GitBook
On this page

Was this helpful?

  1. NETWORKS
  2. supported-networks

Polkadot

This section outlines how to use our API endpoint to connect to Polkadot.

Last updated 7 months ago

Was this helpful?

Polkadot is a blockchain platform that enables the creation of a network of interoperable and secure specialized blockchains called parachains. It aims to solve traditional blockchain networks' scalability, interoperability, and governance issues by facilitating seamless communication between blockchains while maintaining high-security standards.

How to Connect to Polkadot

Using Public Endpoint

You can connect to polkadot using Blockops public API endpoints. These endpoints are only suitable for testing. Public RPC endpoints are not intended for dApp building. (Throughput rate limited to 50 rps).

We have different rate limits set for private API endpoints (e.g. ones with API keys attached) - Read more below

To avoid rate limiting and service interruption, to get your own API key.

For Polkadot Mainnet

https://polkadot-public-rpc.blockops.network/rpc

For Polkadot Westend

https://westend-rpc.blockops.network/rpc

For Polkadot Mainnet

wss://polkadot-public-rpc.blockops.network/ws

For Polkadot Westend

wss://westend-rpc.blockops.network/ws

The below example uses the public API endpoint to make a request on the terminal

Using curl

curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlock"}' 'https://polkadot-public-rpc.blockops.network/rpc'

Using wscat

  • Download wscat from

  • Install wscat by running the following command: npm install -g wscat

wscat -c 'wss://polkadot-rpc.blockops.network/ws' --header 'authorization: APIKEY xxxx'

Using Private Endpoint

Using API keys on an RPC node provides better tracking and monitoring of API usage.

Secure your data, speed up your queries, and take control of your API usage with our RPC API endpoint and personalized API keys. to get your own API key.

To get your API key, create a project using a unique Identifier as the project name and select Polkadot from the network options.

Open the project to view your api key and rpc endpoints.

Send requests

All requests are POST requests.

Connect via Command Line

You can connect to the network using websocket or HTTP with your API key in two ways:

  • Adding the API key as a query string ?api_key=${APIKEY}

  • Or the request header -H 'authorization: APIKEY ${APIKEY}'

Curl

For example, the following CURL command can be used to get header and body of a relay chain block.

curl -H "Content-Type: application/json" -H 'authorization: APIKEY xxxx'  -d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlock"}' https://polkadot-rpc.blockops.network/rpc

Here is the response you will receive back.

{"jsonrpc":"2.0","result":{"block":{"header":{"parentHash":"0x381dd358f0b1e328e861822b2a51a72e8dc064803a5c7ccc96277da3b16d7667","number":"0xe07a1d","stateRoot":"0xa2aacd7ef5d7ff66da1df6643b3e1c13975d210363c568f1bed51bad56cf40db","extrinsicsRoot":"0x00bc7f1504c9a07364835d80d2114ca3d4e7ad774453198b119bea9be2a1f7c1","digest":{"logs":["0x0642414245b50103d8000000d17aae1000000000768dc1931ba697bb9ab4a08debf5d710bd1f55e6325d65315161c2340cc0217170dfe2df24a3680c8ff48868ac665f4b34ebefa4bc844d510c848d9fc99252035db579a0acbf52cded336d6daf6ab7fdb1d1eee0d480e6388c2a12785d4de809"]},"justifications":null},"id":1}

Wscat

If you want to send data requests with WebSockets, you can use several libraries or wscat. You can install and use wscat as follows:

  • Install wscat by running the following command: npm install -g wscat

You can connect to the network with wscat using two options by adding the API key as a query string.

wscat -c 'wss://polkadot-rpc.blockops.network/ws?api_key=*********************'

Or the request header.

wscat -c 'wss://polkadot-rpc.blockops.network/ws' --header 'authorization: APIKEY xxxx'

After executing the command, the terminal will display a message indicating that the connection has been enabled successfully.

Connected (press CTRL+C to quit)
>

Then, you can send the following request:

{"id":1, "jsonrpc":"2.0", "method": "chain_getBlock"}

Quick Links

Download wscat from

For more information on the Polkadot network, please see the official .

Login or set up an account to get started!

sign up now
https://www.npmjs.com/package/wscat
Sign up now
https://www.npmjs.com/package/wscat
Polkadot developer documentation
here
Website
Github
Create a Polkadot project
view Polkadot project