Demonstration of BSN Permissionless Services
Introduction
BSN (Blockchain-based Service Network) is the blockchain infrastructure-as-a-service for decentralized applications (smart contracts) deployment and consumption. In my previous article I showed how to deploy a sample chaincode (from Hyperledger Fabric) on the BSN Testnet for Permissioned Services. We also saw how to access the chaincode deployed in BSN through BSN specific API.
Besides permissioned blockchain platforms, BSN also provides Permissionless Services. In short, BSN provides gateway services to a number of permissionless blockchain networks. Through the gateway we can access our accounts and invoke functions of smart contracts deployed in these permissionless blockchain networks. In this article I will show how to create BSN Permissionless Service, and how to access the services through the BSN gateway.
BSN Permissionless Service
In my previous work I have introduced a quick overview on BSN itself and BSN Permissioned Service. You can refer to it for a quick introduction about BSN. Here I only make an introduction to the BSN Permissionless Service.
As we all know, there are quite many mature permissionless blockchain networks running today. BSN Permissionless Service provides gateway services to a large number of them, and gives us a single management point to access them. BSN keeps growing the list of permissionless blockchain networks supported. As of today (December, 2020), we have seen the following in the list
- Ethereum (Mainnet, Ropsten)
- EOSIO (Mainnet, Testnet, Mainnet-dfuse)
- Tezos (Mainnet, Carthagenet)
- Nervos (Mainnet, Aggron)
- NEO (Mainnet, Testnet)
- Irisnet (Mainnet, Nyancat)
- Algorand (Mainnet, Testnet)
- Solana (Mainnet, Testnet)
- ShareRing (Mainnet, Testnet)
- BitYuan (Mainnet, Testnet)
- Polkadot (Mainnet, Westend)
- Oasis (Mainnet, Testnet)
The service is quite straightforward, and uniform across these networks. For each project we select the network we wish to access. Project ID and Project Key (optional) will be received. These are the important components when we access the selected network. BSN also provides the gateway detail when accessing the service. This gateway information will be incorporated into our client applications.
Demonstration of BSN Permissionless Service
Create a Project for Ethereum Mainnet
Here we walk through how to create a BSN Permissionless Service, and perform a simple REST API access to this network. We are using https://bsnbase.io. Register an account if you have not yet. Choose a plan to fit your case. In my case I am using the free plan, with three projects and limited daily requests and TPS.
By selecting Permissionless Services in left panel you can see this dashboard.
As we saw in bsnbase.io, there are three cities providing permissionless services. Here we select HongKong PCN (Public City Node).
We create a new project, providing a project name and select the blockchain network we are going to access. Here we select Ethereum Mainnet.
And we see the project is successfully created.
We see the Project ID for our Eth-Mainnet project, and BSN provides Access Addresses when we access through REST API or Web Socket. We see no Project Key by default.
In the Action we can enable Project Key, which is used with the x-api-key
header when we access the gateway. For demonstration purposes we enable it.
The creation is complete and the gateway is ready for use. We will do a quick test with this REST API.
Access Ethereum Mainnet through BSN Permissionless Service
We use Postman to access the service we just created. We simply obtain the latest block in Ethereum Mainnet. Note that we are using the Access Address above as the target.

And we need a header x-api-key
holding the Project Key we just enabled in our project.
And here we get the result (0xafc7f6 = 11519990).
We see the result match the explorer.
We can access Ethereum Mainnet through this access address (gateway).
Access BSN Permissionless Service
With the Access Address and optional Project Key, we can access the network with our friendly SDK. Here I have two projects created, one for Ethereum Ropsten and one for Algorand Testnet. I am using JavaScript SDK to access gateways.
I have deployed an ERC20 token contract in Ethereum Ropsten. We specify the Access Address of BSN is placed as HTTP Service Provider (line 2). Here we are using web3.js
library.
And here is the result
As expected, if we use another gateway service, say Infura for Ethereum, we will get back the same result. Note the HTTP Provider is updated with Infura gateway (line 2). Everything is kept unchanged.
And we get the same result.
It is an obvious result as both Infura and BSN permissionless service are same in nature, to access the same Ethereum network (Ropsten here) and therefore we get back the same result.
Similar result is observed in Algorand Testnet. Here I simply check the balance of a given account (shown as amount in the result).
Using BSN Gateway (line 3)
And the result is,
When using PureStake gateway service (line 3),
We again get back the same result.
Statistics of Permissionless Service
BSN also provides the statistics for what we have demonstrated. Here we see the transactions we made for this demonstration on the projects.
Summary
BSN provides a single place to create and manage gateway services to multiple permissionless blockchain frameworks. We have demonstrated how to create a project of Permissionless Service in BSN, and how to check account balance (Algorand Testnet) and access a token contract (Ethereum Ropsten) through the BSN gateways. We see the same result whether we are using BSN gateway, or accessing the networks through other gateway services (PureStake in Algorand, Infura in Ethereum).
Hope you have got more ideas about BSN services, both Permissioned Services in my previous article, and Permissionless Services here.