Introducing the Lit Protocol Event Listener

The new Lit Protocol event listener server and SDK package are now live, enabling event-driven transaction execution and powering use cases such as chain signatures.

Introducing the Lit Protocol Event Listener

We’re excited to announce the Lit Event Listener, a new SDK package that enables developers to use on and off-chain data and events to orchestrate decentralized keys managed by Lit Protocol.

The Event Listener is a TypeScript library that enables developers to create complex and fully programmable workflows with Lit, including the ability to:

  • Listen to custom blockchain events or pull in any off-chain data (via API)
  • Create custom transaction triggers using boolean operators or “If…Then” statements
  • Automate Lit Action execution with custom triggers
  • Simplify PKP and Capacity Credit creation
  • And more…

In this post, we’ll provide an overview of the automation package, how it works, and specifically how it can be used to perform cross-chain operations through the creation of Chain Signatures.

How It Works

Lit Protocol’s new Event Listener introduces a robust system for creating automated workflows with Lit Actions and PKPs that have the ability to respond to both on-chain and off-chain events. At its core is a flexible state machine implementation that allows developers to define states, transitions, and listeners to enable powerful automations that span the entire Web.

Key Features

  1. Listeners: The following listeners have been implemented into the declarative Event Listener interface and are available out of the box:
  • EVMBlockListener: Listens for new blocks on EVM-compatible networks.
  • EVMContractEventListener: Monitors smart contract events on EVM chains.
  • TimerListener: Triggers events based on specific time intervals.
  • FetchListener: Polls off-chain HTTP endpoints for updates.
  • IntervalListener: Runs recurring functions at specified intervals.

It is important to note that the functional interface is capable of listening to any event that can be written in code, such as waiting for human input or monitoring a local IoT device. We encourage you to contribute to or fork this repo to add your own custom Listener and extend what is possible with this tool. 

  1. State Machine: Define states and transitions that automate workflows based on monitored events:
    1. Move between states when specific on-chain or off-chain conditions are met.
    2. Run Lit Actions, send transactions, or execute custom logic within each state.
  2. Actions and Automations:
    1. Mint and manage Programmable Key Pairs (PKPs) and Capacity Delegation NFTs.
    2. Trigger Lit Actions to sign, encrypt, or execute computations.
    3. Automate transitions such as broadcasting transactions, reading from chains, or executing timers.
  3. Integration Flexibility:
    1. Use declarative or functional interfaces to customize workflows, enabling advanced logic tailored to specific use cases.

Chain Signatures with Lit: Unifying Cross-Chain Operations

The term "chain signatures" describes a process where a user or account on one blockchain can securely control or interact with an account on another blockchain. Chain signatures present a path to achieve true cross-chain interoperability by enabling developers to seamlessly coordinate workflows and transactions across networks.

With the Lit Event Listener, developers can easily power chain signatures atop Lit’s decentralized key management infrastructure. Builders can use the tool to monitor events on and across any blockchain network and trigger transactions with Lit keys when these conditions are met, meaning the types of cross-chain operations that can be performed are virtually unbounded.


How It Works:

  1. Monitor Events: Use the Event Listener to listen for activity on any “source” blockchain. For example:
    • Detect a token transfer, smart contract event, or user intent.
  2. Trigger a Transaction: When the defined condition is met, generate a signature using a Lit PKP. This signature can then be broadcast to any “destination” chain and used to authorize a transaction.

Example: Creating Chain Signatures

Here is a practical example of using the Event Listener to generate a chain signature. We listen for custom 'transaction request' events on an origin chain (Base Sepolia) and use them to execute the specified transaction on the destination chain (Ethereum Sepolia):

  1. Monitor Events on Source Chain: The TransactionEmitter contract is deployed to Base Sepolia and listens for transaction requests. 
  2. Receive Event from Source Chain: When a transaction request is received, a TransactionIntentCreated event is emitted from the contract that contains all of the requisite info to construct a transaction on the destination chain.   
  3. Construct Transaction for Destination Chain: After the event is received, the automation script decodes the transaction data, constructs the transaction, and broadcasts it to the destination chain, using a PKP to generate the signature. 

This example demonstrates the power of using Lit to create chain signatures to automate workflows and bridge previously isolated ecosystems, all while leveraging secure and decentralized infrastructure. 


Conclusion

The Lit Event Listener unlocks new possibilities for building complex and secure workflows that span the entire Web. Enabling developers to monitor events across any blockchain or off-chain system, define conditional triggers, and automate transactions using Programmable Key Pairs (PKPs) and Lit Actions, Lit makes it easier than ever to build in Web3. Whether it’s executing cross-chain swaps, automating responses to smart contract events, integrating off-chain data in your dApp, or creating complex long-running workflows that incorporate all of the above, the Event Listener offers flexibility, security, and ease of use.

To get started with this tool right away, check out the official SDK package on NPM and associated event listener server. To use this tool in the context of creating chain signatures, check out the associated example repo

If you’re a developer looking to build with Lit for the first time, get started using the developer docs.