Building DApps on Casper Using BSN
The Casper protocol powers the first fully decentralized, proof-of-stake blockchain network. Casper allows businesses to create new markets and unlock value by tokenizing nearly any asset without compromising performance or security.
The Blockchain-based Service Network (BSN) helps DApp developers spin up a Casper node in minutes to test and deploy smart contracts before launching them on the Casper Testnet or Mainnet. A DApp is a distributed ledger technology application.
This article serves as a quick introduction to help you deploy and interact with a Casper node using BSN. For more information, please visit the BSN User Manual.
Step 1. Create and log into your BSN account.
1.1. Navigate to the BSN official website to create your BSN account.
1.2. Enter the information required.
1.3. Activate your BSN account by following the confirmation link in your email and log into your BSN account.
Step 2. Create a new Permissionless Service.
2.1. Navigate to the Permissionless Services tab in the left navigation bar.
The Permissionless service mainly provides developers who develop public chain DApps, with a unified access service covering numerous public chain nodes.
2.2. Select your desired Public City Node (PCN) location.
With BSN, each PCN is a virtual data center used to allocate a portion of resources from the cloud service or data center on which it operates. This example demonstrates the Hong Kong PCN.
2.3. Select your desired BSN plan.
Developers may choose different BSN portal plans and simultaneously deploy DApps and process transactions on all BSN-adapted public chain nodes.
BSN offers a free plan and different premium plans. The free plan includes up to 2,000 requests per day. There are three premium plans, priced at $20, $100, and $500 per month. The premium plans include up to 40,000 requests, 250,000 requests, and 1,500,000 requests, respectively, per day. All requests can be assigned to any public chain freely.
Step 3. Create your Casper project.
3.1. Select “Create New Project” and give your project a name.
3.2. Choose the Casper-Testnet or the Casper-Mainnet public chain. We recommend always starting your development on the Casper-Testnet.
Congratulations on creating your Casper project! At this point, you should be able to see your Project ID, Project Key, and Access Address.
The “Access Address” is the RPC node URL that your DApp will use.
3.3. Generate a project key for privacy.
To make the RPC node URL only accessible to yourself or your team, you can generate a project key.
Click on the Action ellipsis to the right of your project details, and select the Enable Key option to generate a project key.
Going forward, you will need to submit the project key as the value for the x-api-key parameter in the request header.
You will need this project key to interact with the Casper node the BSN framework will create for you.
Step 4. Interact with the Casper node via its RPC APIs.
In this example, we will use Postman to retrieve the peers of the Casper node we set up with BSN in the previous steps.
4.1. Create a new request entitled “info_get_peers” and choose the POST option.
4.2. Set the request URL to the “Access Address” created in step 3.2. You need to append “rpc/info_get_peers” to the “Access Address” URL, as shown in the screenshot.
4.3. Set up the request headers.
Add the “Content-Type” header with value “application/json” and the “x-api-key” with the project key from step 3.3.
4.4. For the request body, select the “raw” and “JSON” options. Then, fill in the following request body:
You are now ready to send your request.
4.5. Observe the response. If your response returns the addresses of other Casper nodes, you have set up your BSN project correctly.
To try more examples of using the Casper RPC Endpoints, visit the Casper RPC documentation.
Thanks to BSN, you are now ready to develop your DApps on the Casper Network without operating a Casper node.
Here are some additional resources we hope you will find helpful:
● Developers: https://casperlabs.io/developers/getting-started
● Grants: https://www.devxdao.com/
● Casper Network: https://casper.network/en/network
● Discord: https://discord.com/invite/Q38s3Vh
● Telegram: https://t.me/casperblockchain
● Twitter: https://twitter.com/Casper_Network
Join us, and let’s build the decentralized future together!