Skip to content

Instantly share code, notes, and snippets.

@ChristianOConnor
Last active February 6, 2023 22:50
Show Gist options
  • Save ChristianOConnor/ec511d32251325b2d3a1695eb7a44a6b to your computer and use it in GitHub Desktop.
Save ChristianOConnor/ec511d32251325b2d3a1695eb7a44a6b to your computer and use it in GitHub Desktop.
Trying to call a Lit Action through an express server
const express = require("express");
const cors = require("cors");
const litJsSdk = require("lit-js-sdk");
const app = express();
var corsOptions = {
origin: "*"
};
app.use(cors(corsOptions));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.get("/", async function (req, res) {
try {
res.send(await signatures);
} catch (e) {
console.log(e)
res.send('error');
}
console.log(req.query.authSig)
});
const signatures = async () => { await litJsSdk.LitJsSdk.litNodeClient.executeJs({
ipfsId: "Qme9L6jU4CStoBZL7etpwPVX7XPWJ59Z9IFXoTPXyfgXrT",
authSig,
// all jsParams can be used anywhere in your Lit Action Code
jsParams: {
// this is the string "Hello World" for testing
toSign: [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100],
publicKey:
"<MY PUBLIC KEY HERE>",
sigName: "sig1",
},
})};
// set port, listen for requests
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}.`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment