examples: add Lit Triggers examples (release-attestation, uptime-insurance, chainlink-feed-mirror)#408
Conversation
First full-package Lit Triggers example, matching the examples/ convention (action + contract + setup.js + deploy.js + e2e client + README): A webhook trigger receives a GitHub release event, verifies X-Hub-Signature-256 HMAC over the raw body, and — only for genuine published releases — broadcasts an attest() tx to ReleaseRegistry, signed by the wallet derived from the action's IPFS CID (pinned as the contract's immutable attester). Unlike the request/response examples, the action broadcasts itself (a trigger has no downstream caller), so setup funds the action wallet. setup.js: action CID -> group -> scoped key -> derive + fund action wallet -> deploy -> interactive lit-triggers authorize -> create webhook trigger. Runtime verified end-to-end on Base Sepolia via deploy.js + attest.js. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
These depend on the lit-triggers service (the parent-folder examples call the Lit Action endpoint directly), so group them in a subfolder. Adds a subfolder index and a Lit Triggers section in the top-level examples README. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
✅ Full
Then The browser-authorize step (step 9) used the reuse path; the interactive handshake itself was exercised earlier in development. |
Two more full Lit Triggers example packages under examples/lit-triggers/, built and verified end-to-end on Base Sepolia: - uptime-insurance (schedule): parametric insurance. A cron trigger checks a status page; on a major/critical incident it pays ETH to the policyholder from the action's own keyless wallet (the pool). No contract — the pool is the wallet balance. Verified: scheduled run paid out, confirmed by balance delta. - chainlink-feed-mirror (chain_event): relays a Chainlink AnswerUpdated on a supported source chain to a PriceConsumer on any destination chain, signed by a keyless relayer pinned as the consumer's updater. Hardened: dest-chainId pin in the action, updater + stale-round guards in the contract. Verified via deterministic --simulate (PriceConsumer roundId advanced on-chain). setup.js call() now retries transient 5xx / non-JSON responses from the Lit API (hit a flaky HTML error during testing). Updates the examples indexes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Address findings from a codex adversarial pass on the three examples: - chainlink-feed-mirror [P1]: the action trusted the trigger's decoded log, so a usage-key holder could relay an arbitrary price. It now re-fetches the receipt by (tx hash, log index) from a hostname-pinned, https-only source RPC, verifies the emitter is the baked SOURCE.aggregator with the AnswerUpdated topic + confirmations, and decodes the price from the verified log. destChainId is now required. setup warns if the proxy's aggregator drifts from the baked one. --simulate now replays a real on-chain AnswerUpdated (a forged price is ignored / a wrong-emitter tx is rejected). Verified live: real price relayed; wrong-emitter tx rejected with consumer unchanged. - PriceConsumer [P2]: replace the `roundId != 0` first-write sentinel with an explicit `initialized` flag, so a roundId==0 write can't bypass stale-round. - uptime-insurance [P1]: with DEMO_FORCE_DOWN it pays every tick. setup now creates the schedule trigger DISABLED; claim enables it, catches one payout, and disables it again. Verified live (disabled → +0.0002 ETH payout → disabled). - release-attestation [P1/P2]: document the real trust boundary — params.secret is caller-controllable for direct calls, so the HMAC only gates the public webhook path; the usage key is the trust root, and encrypting the secret (Lit.Actions.Encrypt, needs a PKP) is the production fix. Note commitish may be a branch, not an immutable SHA. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Addressed codex adversarial reviewRan a codex challenge pass; applied + live-verified fixes for the actionable findings. [P1] feed-mirror trusted unverified trigger data → the action now re-fetches the receipt by
[P1] uptime drains by default → [P2] PriceConsumer round-0 sentinel → replaced [P1/P2] release-attestation trust model → README now states plainly that Accepted as known/by-design (documented): plaintext keys in gitignored |
Per review feedback: a reader landing on one example shouldn't hit references to sibling examples. - _env.js headers no longer point at ../../compliance-transfer-gate (a path that was also broken from the deeper lit-triggers/ nesting); each now just says it's kept inline so the folder is self-contained, matching #420. - chainlink-feed-mirror README now names the "hostname-pinned RPC trust-anchor" pattern and links to docs/lit-actions/patterns.mdx instead of describing it as another example's solution. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Summary
Adds
examples/lit-triggers/— full, runnable Lit Triggers examples, each matching theexamples/convention (hardened action + contract +setup.js+ e2e client + README with flow diagram & trust model). They're grouped in a subfolder because they depend on the lit-triggers service (the parent-folder examples call the Lit Action endpoint directly).Every on-chain example signs with the action's own keyless wallet (derived from its IPFS CID). And because a trigger has no downstream caller, the action broadcasts the tx itself — so
setupfunds the action wallet.release-attestationReleaseRegistry(action wallet pinned asattester).uptime-insurancechainlink-feed-mirrorAnswerUpdatedto aPriceConsumeron a chain Chainlink doesn't serve. Hardened: dest-chainId pin (action) + updater & stale-round guards (contract).setup.jsflow per example: action CID → group → scoped usage key (from your master key) → derive + fund action wallet → deploy contract (where applicable) → interactive lit-triggers browser authorize → create the trigger.call()retries transient 5xx/non-JSON from the Lit API.Verified end-to-end on Base Sepolia
setupincl. master-key minting + the real browser-authorize (clicked) +attest()e2e; registry reads back. Also exercised the full authorized-token API surface (CRUD, disable→reject→enable, 401 for unauthorized).setup+claim: scheduled run paid out, confirmed by the policyholder +0.0002 ETH balance delta.setupresolved the live Chainlink aggregator + deployedPriceConsumer;mirror --simulaterelayed a price (roundIdadvanced on-chain, runsuccess, tx confirmed).Notes
🤖 Generated with Claude Code