Skip to main content

Table of Contents

Welcome

Welcome to the Lit Actions SDK Docs. These functions can be used inside a Lit Action. You should prefix each function with “Lit.Actions.” so to call “encrypt()” you should do “Lit.Actions.encrypt()” To understand how these functions fit together, please view the Quick Start guide and Lit Actions overview

Encryption

Encryption and decryption functions. These functions are used to encrypt and decrypt data. The data is encrypted & decrypted using a symmetric key derived from the secret key of the PKP.

Lit.Actions.Encrypt

Parameters

  • params Object
    • params.pkpId string The ID of the PKP
    • params.message string The message to encrypt
Returns Promise<string> The ciphertext

Lit.Actions.Decrypt

Decrypt data using AES with a symmetric key

Parameters

  • params Object
    • params.pkpId string The ID of the PKP
    • params.ciphertext string The ciphertext to decrypt
Returns Promise<string> The decrypted plaintext

PKP Keys

Key management functions for PKPs and for action identity keys. getPrivateKey returns a PKP’s key and is checked against group membership. The three getLitAction* functions deal with the key every action derives from its own CID; see Two kinds of keys. All key-returning calls share one limit of ten per execution (Limits).

Lit.Actions.getPrivateKey

Get the private key for a PKP wallet

Parameters

Returns Promise<string> The private key secret

Lit.Actions.getLitActionPrivateKey

Get the private key for the currently executing Lit Action. The key is a secp256k1 scalar deterministically derived by the TEE’s KMS from this action’s IPFS CID, so it is stable across executions and nodes, and changes if any byte of the action source changes. No PKP or group permission is required: every action can read its own key. Returned as 0x-prefixed hex; strip the prefix before feeding it to non-ethers libraries. See Action-Identity Signing and Derived Actions. Returns Promise<string> The private key secret, 0x-prefixed hex

Lit.Actions.getLitActionPublicKey

Get the public key for a Lit Action by IPFS ID. Works for any CID, including actions that are not in any of your groups and have never been executed: the key is public information. Use it to verify signatures or receipts produced by another action, for example an issuer action whose CID is stamped into this one. See Signed Data in Untrusted Storage. Returned as 0x-prefixed SEC1 hex. Counts toward the per-execution key-operation limit.

Parameters

  • params Object
    • params.ipfsId string The IPFS ID of the Lit Action
Returns Promise<string> The public key

Lit.Actions.getLitActionWalletAddress

Get the EVM wallet address for a Lit Action by IPFS ID. Works for any CID with no permission required. Convenient for comparing against ethers.utils.verifyMessage output when verifying another action’s signature. Counts toward the per-execution key-operation limit.

Parameters

  • params Object
    • params.ipfsId string The IPFS ID of the Lit Action
Returns Promise<string> The wallet address

Action Utilities

Helpers available inside actions as Lit.Actions.*.

Lit.Actions.setResponse

Set the response returned to the client

Parameters

  • params Object
    • params.response any The response to send to the client. If this is not a string, it will be JSON-encoded before being sent. A value of undefined is encoded as null.

Debugging

Diagnostic functions for inspecting the runtime state of a Lit Action.

Lit.Actions.showImportDetails

Log and return details of all modules imported by this Lit Action. Returns an array of objects with the resolved CDN URL and SHA-384 integrity hash for each imported module. The details are also written to the action’s console log via the print opCode. Returns Array of objects, one per imported module, each with a url string (the resolved CDN URL) and a hash string (the SHA-384 integrity hash)

Runtime Globals

Globals automatically available inside the Lit Action runtime.

LitActions

Global reference to the Lit Actions namespace for convenience. This alias is injected in the Lit Action execution environment and mirrors Lit.Actions.

ethers

The ethers.js v5 API exposed to Lit Actions for interacting with EVM chains. Includes wallets, providers, contracts, and cryptographic helpers.