Cross-chain service

更新时间:
复制 MD 格式

Cross-chain data connection service

Cross-chain Data Connection Service is a service from Ant Blockchain that supports trusted data interaction between homogeneous and heterogeneous blockchains for enterprise applications. The service uses a protocol stack and cross-chain contracts in the underlying blockchain to enable trusted interaction. This builds a blockchain value network, allows the trusted flow of on-chain value, and enables various inter-chain operations.

The Cross-chain Data Connection Service breaks down data silos between different blockchain consortiums and enables trusted data exchange. For example, it connects data pathways for upstream and downstream consortiums in a supply chain or enhances mutual trust between different consortiums.

The Cross-chain Data Connection Service is currently in public preview. You can request a trial.

Cross-chain service invocation link

To use the Cross-chain Data Connection Service, you must register your blockchain with the service and install the cross-chain contract. Your business contracts then interact with the cross-chain contract to exchange information between different chains.合约开发

Data interaction methods

The Cross-chain Data Connection Service currently supports two data interaction methods:

  • Ledger data access: A target blockchain directly accesses data on a source blockchain through the cross-chain service.

  • Contract message push: A source blockchain sends a message to a smart contract on a target blockchain through the cross-chain service. The smart contract on the target chain then processes the message.

Use the cross-chain data connection service

Enable the service

You can submit a request to enable the Cross-chain Data Connection Service in the Ant Blockchain Cross-chain Service console.服务开通

Register a blockchain

Register the blockchain that you want to use for cross-chain operations in the cross-chain service. After registration, the blockchain receives a unique chain domain name as its identity. The Cross-chain Data Connection Service then uses a cross-chain contract to access your blockchain and transfer cross-chain information.

  1. Click Register Blockchain to go to the registration page.

  2. Select the type of blockchain to register and complete the registration steps. This service currently supports Ant Blockchain and Hyperledger Fabric. To register other types of blockchains, you can submit a ticket.

Register an Ant Blockchain

  1. Set Blockchain Type to Ant Blockchain. The system automatically retrieves the list of your blockchains on the Ant Financial Ant Blockchain BaaS platform. Select the blockchain that you want to register from the list.

    Note

    Only the consortium administrator of the Ant Blockchain has permission to perform this operation.

  2. Create a domain name for the blockchain. This domain name serves as the unique identity of the blockchain during cross-chain authorization.

Register a Hyperledger Fabric blockchain

  1. Complete the following preparations.

    Create an organization and add it to a consortium. Create a channel for the business that requires cross-chain operations, and create a user for the cross-chain service. The cross-chain service uses this user's identity to perform data synchronization.

    Note

    Hyperledger Fabric uses channels for business isolation. Each channel that requires cross-chain operations must be registered in the cross-chain service.

  2. Open the registration page and fill in the required information.

    Set Blockchain Type to Hyperledger Fabric. Follow the on-screen instructions to complete the registration.

  3. Download the cross-chain chaincode package and upload it to the channel in Alibaba Cloud BaaS. For more information about uploading chaincode, see Management chaincode. Then, install and instantiate the cross-chain chaincode.

    Important

    The cross-chain chaincode must be on the same channel as the business chaincode.

  4. Create a user for the cross-chain service and download the user's software development kit (SDK) configuration.SDK配置

  5. Unzip the SDK configuration package.

    Retrieve and upload the connection-profile-standard.yaml configuration file.

  6. Configure the remaining information.

    Because the connection-profile-standard.yaml file contains information about all channels and peer nodes, you must select the channel for the cross-chain operation and the related peer nodes for validation. Enter the username and password for the user that was created for the cross-chain service.

Registration complete

After the registration is complete, you can view information about the registered chain in the console.

注册成功

Cross-chain authorization

  1. To the right of the registered blockchain, click Details to go to the details page.

  2. Click the Cross-chain Authorization tab to go to the Cross-chain Authorization page.

Ledger data access authorization

Grant another registered blockchain permission to access the ledger data of the current blockchain through the cross-chain service.

The following data types can be accessed:

  • Ant Blockchain transactions

  • Ant Blockchain Block

  • Ant Blockchain block headers

账本授权

Note

In the authorization example shown in the figure, the blockchain crosschain1.oracle.chain allows the blockchain crosschain2.oracle.chain to directly read on-chain transaction information through the cross-chain service.

Contract message push authorization

Grant a specified contract on another registered blockchain permission to send messages to a specified contract on the current blockchain.

合约消息授权

Note

In the authorization example shown in the figure, the blockchain crosschain1.oracle.chain allows the contract sourceContract on the blockchain crosschain2.oracle.chain to send messages to the contract destContract on crosschain1.oracle.chain. The destContract then processes the messages.

View authorizations

After the authorization is successful, you can view information about the authorization under My Permissions.

授权查看

Business contract development

Ledger data access development flow

To use the ledger data access API operation in a user smart contract, follow these steps:

  • Obtain the ledger data contract name from the Ant Blockchain BaaS platform.

  • Obtain the ledger data access API operation definition (ChainDataInterface.sol).

  • Import the ledger data access API definition into the user contract.

  • Implement the callback interface in the user contract to asynchronously receive ledger data callbacks.

  • Build a ledger data access request in the user contract (ChainDataCmdHelper.sol).

  • Send the request from the user contract to the ledger data contract. For more information, see the API usage examples.

  • The ledger data service returns data in JSON format. For more information about the format, see the ledger data structure section.

Development reference for business contracts:

Contract message push development flow

To use the contract message push service API operation in a user smart contract, follow these steps:

  • Obtain the message contract name from the BaaS platform.

  • Obtain the contract message push API operation definition.

  • Import the contract message push API operation into the user contract.

  • Implement the message receiving interface in the user contract to be called by the cross-chain message contract.

  • Call the message sending interface of the cross-chain message contract from the user contract.

Development reference for business contracts: