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
- The cloud service integration function is installed. For more information, see Install the cloud service integration module.
- Cloud service integration sample code is downloaded.
- Function Compute tool funcraft is installed. For more information, see funcraft introduction and installation method.
Procedure
- Go to the sample code directory
mns2blockchain
.- 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.
- Modify the method and parameters for calling the smart contract based on comments and service scenarios.
- 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.
- In the mns2blockchain directory, execute
fun deploy
to deploy a function in the Function Compute service. - Create a topic in Alibaba Cloud Message Service MNS. For information about how to use Alibaba Cloud MNS, see MNS Quick Start.
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).
In the Alibaba Cloud MNS console, send a test message to the MNS topic.