Getting started
First request

First request to DRPC

First, get your endpoint.

Authentication

Each endpoint on UI by default contains your authentication key as a URL parameter dkey and network as network.

For example, ethereum network of DRPC will look like this: https://lb.drpc.org/ogrpc?network=ethereum&dkey=YOUR-DRPC-KEY.

Another recommended way for authentication is to use special HTTP header Drpc-Key.

The following are examples of how to make a requests:

curl -X POST -H 'Content-Type: application/json' \
-d '{"method": "eth_blockNumber","params": [],"id": "1","jsonrpc": "2.0"}' \
'https://lb.drpc.org/ogrpc?network=ethereum&dkey=YOUR-DRPC-KEY'

DRPC key value is the part of your endpoint by default. Also, you can find it on the Key -> Settings page: Example of the key value on Settings page

Making requests from code

DRPC conforms to standard JSON RPC protocol, that most of the blockchains use today. So, you can use any standard library for you preferred language to make request, for example:

let Web3 = require("web3");
let provider = "https://lb.drpc.org/ogrpc?network=ethereum&dkey=YOUR-DRPC-KEY";
let web3Provider = new Web3.providers.HttpProvider(provider);
let web3 = new Web3(web3Provider);
 
// Get the latest block number
web3.eth.getBlockNumber().then((result) => {
  console.log("Latest Ethereum Block is ", result);
});

DRPC SDK

However, there is also DRPC SDK, which supports DRPC protocol, it's an alternative protocol for calling blockchain methods which allows us to do additional things like response verification, provider response signatures client check, etc.

Currently, there is only JS version of this library.

  1. To install run:

npm install @drpcorg/drpc-sdk

  1. You can use typescript to customize your endpoint without UI. We also support providers for ethere.js and web3.js, for example:
import { DrpcProvider } from "drpc-sdk/dist/esm/providers/ethers";
// for cjs
// import { DrpcProvider } from 'drpc-sdk/dist/cjs/providers/ethers';
 
async function getBlock(tag) {
  let provider = new DrpcProvider({
    dkey: "YOUR-API-KEY",
    provider_ids: ["public"],
  });
  let block = await provider.getBlock(tag);
}
  1. You can check the complete docs for our SDK here: https://p2p-org.github.io/drpc-client/ (opens in a new tab)