Create Custom Mantle Endpoint with DRPC

11/17/232 min read

Mantleby Mantle

Developers

Tutorials

Create Custom Mantle Endpoint with DRPC

This guide is intended for developers trying alternative RPCs provided by Mantle Network's partners, such as DRPC. By the end of this guide, users will able to generate a dedicated endpoint that will give them access to the majority of RPC methods required for dApp development and/or blockchain interaction.

https://drpc.org/public-endpoints/mantle

Create DRPC key

  1. Log into or create your account Go to drpc.org/login(opens in a new tab). You can login via your crypto wallet (we support Metamask and Wallet Connect). Or you can log in via email and password.

  2. Create a new key DRPC keys are used to differentiate between different applications or parts of an application. You can set a daily limit for each key, and deactivate it if you suspect that it has been compromised. Additionally, you can view request statistics for each key, which can help you track usage and optimize your application's performance.

  3. Create custom endpoint or use the default one Endpoints are not like keys. Each key can have any number of endpoints. In fact, endpoints are basically URLs consisting of

  • Base DRPC URL address
  • Set key parameter
  • Other URL parameters that define different settings/features for you requests to DRPC By default there is always one endpoint with default DRPC settings. You can select network and protocol for it. This endpoint should be enough for most projects. However, if you need something special you can create custom endpoint. Custom enpdoint allows you to specify different settings like:
  • Select the list of specific providers if you want only them to serve your requests
  • Enable fallback in case those specific providers fail, we will reroute request to available providers
  • Enable DRPC verification, etc.

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);}

You can check the complete docs for their SDK at - https://p2p-org.github.io/drpc-client/

Wrap

🛑 Have doubts and need support? Join our Discord Server and ping the DevRel team for support or interact with other blockchain developers and fellow builders!

💪🏼 Not tired and want to keep building? Head over to https://www.mantle.xyz/blog/developers and check out an amazing list of tutorials to keep building cool dApps on Mantle Network!

Ciao! 👋🏼


Join the Community