Interface LitActionSdkParams

Hierarchy

Properties

jsParams?: any

An object that contains params to expose to the Lit Action. These will be injected to the JS runtime before your code runs, so you can use any of these as normal variables in your Lit Action.

litActionCode?: string

The litActionCode is the JavaScript code that will run on the nodes. You will need to convert the string content to base64.

Example

Buffer.from(litActionCodeString).toString('base64');
litActionIpfsId?: string

You can obtain the Lit Action IPFS CID by converting your JavaScript code using this tool: https://explorer.litprotocol.com/create-action

Note: You do not need to pin your code to IPFS necessarily. You can convert a code string to an IPFS hash using the "ipfs-hash-only" or 'ipfs-unixfs-importer' library.

Example

async function stringToIpfsHash(input: string): Promise<string> {
// Convert the input string to a Buffer
const content = Buffer.from(input);

// Import the content to create an IPFS file
const files = importer([{ content }], {} as any, { onlyHash: true });

// Get the first (and only) file result
const result = (await files.next()).value;

const ipfsHash = (result as any).cid.toString();
if (!ipfsHash.startsWith('Qm')) {
throw new Error('Generated hash does not start with Qm');
}

return ipfsHash;
}

Generated using TypeDoc