When you upload data to a blockchain by using a REST API, you can integrate Alibaba Cloud Blockchain as a Service (BaaS) with the Content Moderation service to check data before the upload. This prevents illegal data from being uploaded to the blockchain.
This topic uses Node. js as an example to describe how to use a REST API to check data compliance before uploading the data to a blockchain.
- The cloud service integration module is installed in the blockchain instance, and Alibaba Cloud BaaS is allowed to integrate with the Content Moderation service.
- Cloud service integration sample code is downloaded.
- Node.js v8.17.0 or later is installed.
- Deploy sample chaincode notary to the channel by referring to Chaincode Deployment.
- Modify main.js in sample code
invoke-with-content-checkby referring to Use REST APIs.
- Go to the
invoke-with-content-checkdirectory and execute
npm installto install the dependencies of the node.
node main.jsto start the instance.
Data 1581905807512 pushed to blockchain with transaction 284d0b2b89db5bc5489127de863d0bb9b9d0a5f05bae67762567a3aff113822a
Content Moderation check failed: Send transaction failed: CONTENT_CHECK returned error VERIFY_FAILED: Content Moderation Check failed, suggestion block. key: 1581905807512, value: <Sensitive data for the test is omitted.>
Content Moderation check failed: Send transaction failed: CONTENT_CHECK returned error VERIFY_FAILED: Content Moderation Check failed, suggestion block. Key: 1581905807512, value: <Sensitive data for the test is omitted.>
If the default content check policies fail to meet your business needs, you can log on to the Content Moderation console and add check rules or adjust check behavior by referring to Custom text library.