|
1 | 1 | # @elizaos/plugin-lit
|
2 | 2 |
|
| 3 | +A plugin that integrates Lit Protocol functionality into the elizaOS runtime environment, enabling secure and decentralized access control and cryptographic operations. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Deploy and manage Lit Actions for programmable cryptography |
| 8 | +- Interact with Lit Agent Wallet for secure transaction signing |
| 9 | +- Built-in tools for common blockchain operations: |
| 10 | + - ECDSA signing |
| 11 | + - ERC20 token transfers |
| 12 | + - Uniswap interactions |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
3 | 16 | A comprehensive blockchain interaction plugin for the Eliza Agent Stack, powered by Lit Protocol's Programmable Key Pairs (PKPs). This plugin enables autonomous agents to perform secure cross-chain transactions through decentralized key management and threshold cryptography.
|
4 | 17 |
|
5 | 18 | ## Overview
|
@@ -37,6 +50,136 @@ The Lit Protocol plugin provides:
|
37 | 50 | npm install @elizaos/plugin-lit
|
38 | 51 | ```
|
39 | 52 |
|
| 53 | +## Setup |
| 54 | + |
| 55 | +There are two ways to register the plugin: |
| 56 | + |
| 57 | +1. Add to your agent's plugins in `agent/src/index.ts`: |
| 58 | + |
| 59 | +```typescript |
| 60 | +import { LitPlugin } from '@elizaos/plugin-lit'; |
| 61 | + |
| 62 | +export default { |
| 63 | + plugins: [ |
| 64 | + // ... other plugins |
| 65 | + litPlugin, |
| 66 | + ], |
| 67 | + // ... rest of your agent configuration |
| 68 | +}; |
| 69 | +``` |
| 70 | + |
| 71 | +2. Or add it in your character configuration: |
| 72 | + |
| 73 | +```typescript |
| 74 | +{ |
| 75 | + name: "YourCharacter", |
| 76 | + plugins: [ |
| 77 | + // ... other plugins |
| 78 | + "@elizaos/plugin-lit" |
| 79 | + ] |
| 80 | +} |
| 81 | +``` |
| 82 | + |
| 83 | +## Quick Start |
| 84 | + |
| 85 | +1. After registration, initialize Lit Protocol: |
| 86 | + |
| 87 | +```javascript |
| 88 | +await elizaOS.lit.initialize({ |
| 89 | + // Your configuration options |
| 90 | +}); |
| 91 | +``` |
| 92 | + |
| 93 | +## Core Components |
| 94 | + |
| 95 | +### Lit Actions |
| 96 | + |
| 97 | +Located in `src/actions/helloLit`, this module provides the foundation for deploying and managing Lit Actions. Lit Actions are JavaScript functions that run in a decentralized manner across the Lit Network. |
| 98 | + |
| 99 | +Example usage: |
| 100 | + |
| 101 | +```javascript |
| 102 | +const litAction = await elizaOS.lit.deployAction({ |
| 103 | + code: ` |
| 104 | + (async () => { |
| 105 | + // Your Lit Action code here |
| 106 | + })(); |
| 107 | + ` |
| 108 | +}); |
| 109 | +``` |
| 110 | + |
| 111 | +### Tools |
| 112 | + |
| 113 | +The `src/actions/helloLit/tools` directory contains pre-built tools for common blockchain operations: |
| 114 | + |
| 115 | +#### ECDSA Signing |
| 116 | +```javascript |
| 117 | +const signature = await elizaOS.lit.tools.ecdsaSign({ |
| 118 | + message: "Message to sign", |
| 119 | + // Additional parameters |
| 120 | +}); |
| 121 | +``` |
| 122 | + |
| 123 | +#### ERC20 Token Transfer |
| 124 | +```javascript |
| 125 | +const transfer = await elizaOS.lit.tools.erc20Transfer({ |
| 126 | + tokenAddress: "0x...", |
| 127 | + recipient: "0x...", |
| 128 | + amount: "1000000000000000000" // 1 token with 18 decimals |
| 129 | +}); |
| 130 | +``` |
| 131 | + |
| 132 | +#### Uniswap Integration |
| 133 | +```javascript |
| 134 | +const swap = await elizaOS.lit.tools.uniswapSwap({ |
| 135 | + tokenIn: "0x...", |
| 136 | + tokenOut: "0x...", |
| 137 | + amountIn: "1000000000000000000" |
| 138 | +}); |
| 139 | +``` |
| 140 | + |
| 141 | +## Agent Wallet Integration |
| 142 | + |
| 143 | +This plugin integrates with the [Lit Protocol Agent Wallet](https://github.com/LIT-Protocol/agent-wallet) for secure key management and transaction signing. The Agent Wallet provides: |
| 144 | + |
| 145 | +- Secure key generation and storage |
| 146 | +- Transaction signing capabilities |
| 147 | +- Integration with Lit Actions for programmable authorization |
| 148 | + |
| 149 | +## Documentation |
| 150 | + |
| 151 | +For more detailed information about Lit Protocol and its capabilities, visit: |
| 152 | +- [Lit Protocol Documentation](https://developer.litprotocol.com/) |
| 153 | +- [Agent Wallet Documentation](https://github.com/LIT-Protocol/agent-wallet) |
| 154 | + |
| 155 | +## Contributing |
| 156 | + |
| 157 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 158 | + |
| 159 | +## License |
| 160 | + |
| 161 | +MIT License |
| 162 | + |
| 163 | +Copyright (c) 2024 elizaOS |
| 164 | + |
| 165 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 166 | +of this software and associated documentation files (the "Software"), to deal |
| 167 | +in the Software without restriction, including without limitation the rights |
| 168 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 169 | +copies of the Software, and to permit persons to whom the Software is |
| 170 | +furnished to do so, subject to the following conditions: |
| 171 | + |
| 172 | +The above copyright notice and this permission notice shall be included in all |
| 173 | +copies or substantial portions of the Software. |
| 174 | + |
| 175 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 176 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 177 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 178 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 179 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 180 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 181 | +SOFTWARE. |
| 182 | +======= |
40 | 183 | ## Configuration
|
41 | 184 |
|
42 | 185 | Required environment variables:
|
|
0 commit comments