Demonstration of BSN Interchain Services Supported by Poly Enterprise
On October 31, 2020, the BSN R&D team completed the quarterly updates and launched BSN interchain services. As one of BSN’s core functions, interchain services support interoperability between two or more independent blockchains in the BSN. It enables the swap and transfer of data, assets, and information.
The BSN Interchain Communications Hub (ICH), the core of interchain services, adopts the cross-chain protocols of heterogeneous chains and double-layer structure design. ICH uses relay chains as cross-chain coordinators, heterogeneous chains as cross-chain transaction executors, and acts as a relayer of cross-chain data.
It has adopted Poly Enterprise and IRITA cross-chain protocols and will integrate more cross-chain protocols soon.
Currently, the interchain services are running on the BSN Testnet, supporting cross-chain calls between multiple permissioned and public blockchains, including Fabric, Ethereum, NEO and FISO BCOS. The commercialization of the interchain services will start at the end of January 2021.
In this demonstration, we will make a Poly Enterprise-based cross-chain call. The smart contract of the source chain is developed on Fabric, and the smart contract of the target chain is developed on FISCO BCOS. Developers can follow this guidance and have free trials.
1. Publish a cross-chain application smart contract
1) Log in to BSN International Portal
Access to www.bsnbase.io, register an account, and log in.
2) Go to Interchain Services -> Testnet Entrance
3) Click Create a Test Service button to deploy a cross-chain application smart contract
Here we use the Fabric-based sample smart contract as the source chain’s smart contract and the FISCO BCOS-based sample smart contract as the target chain’s smart contract.
To correctly zip and upload the smart contracts, please refer to the Fabric smart contract package requirements and FISCO BCOS smart contract package requirements.
4) Click Upload Chaincode Package to upload the chaincode or smart contract package.
Input the information and click confirm to upload the package. Just note that in the Fabric-1.4.3-secp256r1 platform, we use Golang language in the smart contract, so the Main Path is required.
Then click Start Deploying to deploy the smart contract.
2. Get parameters and run the smart contract
1) After successfully deployed the smart contract, click Action -> Details to jump to the information page.
2) In this page, we need to use the information of My Certificate, Access URL, UserCode, AppCode and Chaincode Deployment Name.
3) Copy the Access URL, Usercode, APPcode, Chaincode deployment name, as well as the Certificate and paste them in the off-BSN system in the appropriate place (here we use the official BSN Java SDK as an example), and then the system can call the API and call the smart contract.
As we published the smart contract on Fabric-1.4.3-secp256r1 platform, the private key and gateway public cert key in the certificate zip file should be from secp256r1 folders.
The same situation applies to FISCO BCOS-based smart contracts.
3. Make a cross-chain transaction call
1) In this example, we will make the cross-chain call by using the “say” method:
2) The parameters we need to fill in include the target Chain ID, the target chain’s smart contract address (Without “0x” prefix), the cross-chain message, and the name of the application contract.
The target Chain ID can be found in the table below. As we use International FISCO platform to be the target chain, so the target Chain ID is 7.
The target chain’s smart contract address (Remember to remove “0x” prefix) can be found on FISCO BCOS-based DApp service’s information page.
In this example, we will pass the string “FabricToFisco” from the source chain to the target chain.
Fill in the parameters and then call the target chain, the system will respond with a success result:
3) We can now verify if the target chain has received the message.
In FISCO BCOS SDK, before we check the result, we should firstly register a userID.
Then we use “hearSomeThing” method to acquire the result.
The system responds the result with a hexadecimal text “0x466162726963546f466973636f” in queryInfo.
Finally, we convert the hexadecimal text into a string, and get the result of “FabricToFisco”.
For more detailed information on BSN interchain services, please go to BSN’s User Manual.
We encourage all developers to try interchain services and provide us with feedback and suggestions. Please feel free to contact us anytime at firstname.lastname@example.org.