Usage Off Chain

To use Cicleo Subscription with an external database

To integrate Cicleo with your project's off-chain database, you need to set up a URL that Cicleo will call every time a user changes their subscription status.

Request Type: POST

Request Body Example:

{
    address : "0X95CF5354519A6AD2BD7E53FE7763201DFB24BFE4"//Always in Uppercase
    subscriptionId: 1,
    secret: "LFHIOENDOUDGHIDG",
    endTime: 1679484296 //Still in second timestamp
}

To fully integrate Cicleo with your project's off-chain database, you need to create an API endpoint that Cicleo can call using a secure key. This ensures maximum security when connecting Cicleo's off-chain capabilities with your project's database.

Example of backend

const express = require("express");
const CICLEO_SECRET = ""//To replace with your secret 

const app = express();

//Create a mydomain.com/subscription/set link that i will use for cicleo
app.post("/subscription/set", (async (req, res, next) => {
    //Verify if caller is cicleo
    if (req.body.secret != CICLEO_SECRET) {
        res.status(401).json({ message: "Wrong secret" });
        return;
    }
        
    //Address of the user subscribed
    const address = req.body.address;
    //The subscriptionid of the user
    const subscriptionId = req.body.subscriptionId;
    //And the unix timestamp (second) of the ending of his subscription
    const endTime = req.body.endTime;
    
    
    //Then do your thing to save it !
);

Last updated