GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||
GeezerVison is showing developer.litprotocol.com — Overview - Documentation How can a smart contract trust a price that came from an HTTP API? A contract can’t make HTTP requests, and a server that fetches the price for it is one more party you have to trust. A Lit Action fetches the price inside the TEE and signs it with a key that only that exact code can use. The contract checks the signature, so it knows which code produced the price.
A minimal exampleethers.utils.verifyMessage(payload, signature) and compare the recovered address to the address of this CID, obtained through getLitActionWalletAddress from any other action. Swap getLitActionPrivateKey() for getPrivateKey({ pkpId }) if you want the proof bound to a wallet you manage instead.
What is a Lit Action?A Lit Action is an immutable JavaScript program identified by its IPFS CID and executed inside the Lit network’s TEE. The CID is both the action’s address and a commitment to its code: change one byte and you have a different action. Actions have access to a small SDK that lets them:
How a request reaches your codeYou run an action by sending its code toPOST /core/v1/lit_action with a usage key. The server passes js_params to your main function as its argument, and whatever main returns comes back as response:
What will this action sign with?Start from what the signature has to mean. A price proof should mean “this exact code produced this price”, so it should be signed with a key that belongs to the code itself. A treasury should keep its address when you ship a new version of its logic, so it should be signed with a wallet you manage. Those two needs map to the two kinds of keys below.Two kinds of keysEvery action can reach two different kinds of key. Knowing which to use is most of the design work.
What is a proof?When an action fetches external data (a price, a weather reading, another chain’s state) and signs the result, that signed output is a proof. Anyone holding the signer’s public key can verify that the specific computation produced it. Smart contracts cannot make HTTP requests; a Lit Action can, and can deliver the result on-chain with a signature the contract checks withecrecover.
How actions fit into ChipotleActions are organized within groups. A group binds PKPs to the action CIDs allowed to use them, and usage API keys are scoped to execute within groups./core/v1/lit_action, the server hashes the submitted code to its CID, checks that the API key may execute in a group containing that CID, and only then runs it. Inside the action, every getPrivateKey / Encrypt / Decrypt call is checked again: the named PKP must be in a group with the running CID. There is no IPFS upload step. You send the source and the server derives the CID.
The usage key appears in the tree above because it points at the group through execute_in_groups. The permission is stored on the key, and the group itself doesn’t list keys. Here is the whole path a request takes:
Every request takes this path. A group answers “Can this action use this PKP?” A usage key’s scopes answer “Can this caller use this group?” A wildcard key (execute_in_groups: [0]) passes the first check for any code, but it still needs a group to use a PKP.
Patterns that make Chipotle easierThese four pages describe the load-bearing design patterns. They are what production apps on Chipotle, including the Lit Agent Keychain, are actually built from.Derived ActionsOne audited template, a stamped-in constant, and a new immutable action with its own key per user, secret, or tenant. No PKP to mint. Signed Data in Untrusted StorageHave an action sign the records you store. Consumers verify at runtime, so your database can never forge a permission. PatternsGating logic as code, hostname-pinned RPCs, multi-source consensus, action-identity signing, PKP vaults. SecretsAPI keys and credentials inside actions: PKP vaults, encrypt-to-action, storage, rotation. The action runtimeInside an action, theLit.Actions namespace exposes the SDK. The most used functions:
ethers v5 is a global. Third-party ESM packages can be imported from jsDelivr with pinned versions. Key operations are limited to ten per execution and outbound fetch calls to fifty; see Limits.
Full reference: Lit Actions SDK.
Next stepsTo read this section in order, follow the sidebar: Module Imports, WebAssembly, Examples, Patterns, Derived Actions, Signed Data in Untrusted Storage, Secrets, and Limits. These pages are also useful on their own:
Was this page helpful? | |||||||||||||||||||||||||||||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |