Display on-chain data using DataV

更新时间:
复制 MD 格式

This topic describes how to use Alibaba Cloud Blockchain as a Service (BaaS) as a data source in DataV to display information from a blockchain.

Before you begin, complete the following prerequisites:

  1. Install Alibaba Cloud service integration in your blockchain instance.

  2. You have activated the DataV service.

Display smart contract data

With Alibaba Cloud service integration, you can use smart contract APIs as a DataV data source to display on-chain data in real time. Follow these steps:

  1. Deploy your business smart contract. This topic uses the general evidence storage contract as an example. For more information, see Install and deploy chaincode.

  2. Add a BaaS data source with the following configuration.

  3. Use a REST API or an SDK to invoke the notary chaincode with the following arguments: ["set", "provider", "aliyun"].

  4. On the canvas, add the Universal Title widget. For more information, see Add a widget.

  5. Configure the data source for the widget. Select the BaaS data source that you just created and specify the following parameters. For more information, see Configure a data source.

    {
     "chaincode": "notary",
     "args": [
       "get",
       "provider"
     ],
     "transients": {}
    }
  6. Configure the following data filter to read the data that is returned by the chaincode.

    return [{ value: data.Result }];
  7. On the design canvas, the Universal Title widget displays "aliyun", which is the data stored in the chaincode.

Display chain information

You can use the Alibaba Cloud BaaS OpenAPI to obtain basic blockchain information, such as the number of participants and the block height. The following steps describe how to display the number of blockchain participants in DataV. For more information about the available data, see DescribeFabricExplorer or OpenAPI overview.

  1. Add an OpenAPI data source with the following configuration.

  2. On the canvas, add the Digital Ticker Board widget. For more information, see Add a widget.

  3. Configure the data source for the widget. Select the OpenAPI data source that you just created and specify the following parameters. For more information, see Configure a data source.

    • API Name: DescribeFabricChannelMembers

    • You can specify the parameters as described in the DescribeFabricChannelMembers document. The following code provides an example:

      {
      "ChannelId": "chan-first-channel-xxxxxxxx"
      }
  4. Configure the following data filter to retrieve the number of participants from the result.

    return [{ name: "ChannelMembers", value: data.Result.length, prefix: "", suffix: "" }];
  5. On the design canvas, the digital ticker board displays the number of participants in the current channel.

    DataVOpenAPI