All Products
Search
Document Center

Push MNS Message to Blockchain

Last Updated: Apr 03, 2020

This topic describes how to automatically push messages in Alibaba Cloud Message Notification Service (MNS) to a blockchain by using the Function Compute service.

Prerequisites

  1. The cloud service integration function is installed. For more information, see Install the cloud service integration module.
  2. Cloud service integration sample code is downloaded.
  3. Function Compute tool funcraft is installed. For more information, see funcraft introduction and installation method.

Procedure

  1. Go to the sample code directory mns2blockchain.
    1. Modify the configuration items of index.js based on comments, such as the REST API service address, refresh token, channel name, and smart contract name.
    2. Modify the method and parameters for calling the smart contract based on comments and service scenarios.
    3. Modify the Function Compute service name and function name in template.yml. The default service name is octopus and the default function name is MNS2BlockChain. For more configuration methods, visit funcraft documentation.
  2. In the mns2blockchain directory, execute fun deploy to deploy a function in the Function Compute service.
  3. Create a topic in Alibaba Cloud Message Service MNS. For information about how to use Alibaba Cloud MNS, see MNS Quick Start.
  4. Log on to the Function Compute console, and configure the MNS trigger for the newly created function (in the sample, [Event Format] must be set to JSON).Trigger configurations

  5. In the Alibaba Cloud MNS console, send a test message to the MNS topic.