Build on NEAR using BSN

BSN
BSN Technical Guide
4 min readMay 24, 2021

--

NEAR is a blockchain designed for developing your applications at high speed and scalability with low gas fees, and seamless interoperability with Ethereum.

For the DApp developers who want to build and deploy with their own RPC node, BSN provided a quick and easy solution to set up nodes in minutes.

Here is a quick guide for developers to deploy their own NEAR RPC API server on BSN.

Step 1: Register and Sign In BSN

Go to the BSN official website, and register an account if you haven’t done so.

After filling in all the necessary fields, click “Confirm” button. You will receive an activation email, and set up your account password.

Now let’s login BSN with your account.

Step 2: Select your Plan under “Permissionless Services”

After login, switch to the “Permissionless Services” tab.

We need to choose and purchase one plan. As an example, we’d like to “buy” a node located in “Hong Kong” (you can also choose California or Paris), and we will select the “Free Plan”, and confirm the purchase.

Step 3: Create a NEAR Mainnet Project

Now we have purchased a plan. Let’s move on to create a new project for NEAR Mainnet.

Click “Create New Project” button and fill in the fields of “Project Name”, “Choose the Chain”, and “Daily Requests”.

Upon clicking “Create Project” button, a NEAR Mainnet project will be created.

The “Access Address” is the RPC node URL that will be used by our DApp.

To make the RPC node URL only accessible to ourself, let’s “Enable Key”, and we can copy the “Project Key” which will be used in our next step. (Please keep the key secret only to yourself or your team)

With the help of BSN, now we have set up a RPC node for development, testing and production in several minutes.

Step 4: Call NEAR RPC APIs with the RPC Node

To show how it works, here we’ll demo the RPC APIs with Postman, which is a popular tool used for API development and testing.

After you register and sign in Postman, follow the below steps:

(1) Create a new request called “View Account”;
(2) Switch request type to “POST”;
(3) Fill in the request URL with “Access Address” from our NEAR Mainnet project on BSN;
(4) Under “Headers” tab, add “Content-Type” with “application/json”, and add “x-api-key” with the “Project Key” from our NEAR Mainnet project on BSN.

(5) Under “Body” tab, select “Raw” and “JSON”, and fill in the JSON RPC call with the parameters in https://docs.near.org/docs/api/rpc#view-account and change the account_id.
(6) Click “Send” button to make the request, and we’ll receive response with information about the account “berryclub.ek.near”.

To try more examples of using RPC Endpoints, visit the RPC document: https://docs.near.org/docs/api/rpc

Step 5: Use the Node in Your DApp

With the RPC node we have deployed above, we can use it in NEAR DApps by configuring nodeUrl in near-api-js connection.

As a real world example, you could switch the mainnet node URL of BerryClub from the current one (source code here) to the one you have created, and deploy your own version in minutes.

Conclusion

BSN makes it super easy to set up a self-owned, dedicated NEAR RPC node for development, testing and production within only several minutes.

Learn more about NEAR

To learn about development on NEAR and join our community, please visit the links below:

--

--

BSN
BSN Technical Guide

The BSN is a cross-cloud, cross-portal, cross-framework global infrastructure network used to deploy and operate all types of blockchain DApps.