|
1 | 1 | <div align="center">
|
2 | 2 |
|
3 |
| -[](https://github.com/huggingface/smolagents/releases) |
4 |
| -[](https://github.com/ephemerahq/xmtp-agents/blob/main/LICENSE) |
5 |
| - |
6 | 3 | # xmtp-agents
|
7 | 4 |
|
8 | 5 | </div>
|
@@ -42,16 +39,70 @@ const members = await group.members();
|
42 | 39 |
|
43 | 40 | By default, your bot will have a new address every time you start it up. That's ideal. If you have a private key, you can encode it to a hex string and set the KEY environment variable. Your bot will then use this key to connect to the network.
|
44 | 41 |
|
45 |
| -Don't know how to create a private key? Here's how to do it with ethers.js: |
| 42 | +XMTP uses two types of keys: |
| 43 | + |
| 44 | +1. **Wallet Key**: |
| 45 | + |
| 46 | + - An Ethereum private key (e.g. `0x123...`) that defines your bot’s **on-chain identity** (its public address) (e.g. `hi.xmtp.eth`). |
| 47 | + - By providing this key, messages sent from your bot will be tied to a consistent address. |
| 48 | + |
| 49 | +2. **Encryption Key**: |
| 50 | + - Protects your **local database** of stored messages (it does not affect on-chain identity). |
| 51 | + - If not provided, it’s created automatically and saved to your `.env`. |
| 52 | + |
| 53 | +### 1. Provide a private key |
| 54 | + |
| 55 | +If you already have a key, place it in `.env`: |
| 56 | + |
| 57 | +```bash |
| 58 | +WALLET_KEY=0xYOUR_PRIVATE_KEY |
| 59 | +``` |
| 60 | + |
| 61 | +**Usage**: |
| 62 | + |
| 63 | +```ts |
| 64 | +const agent = await createClient({ |
| 65 | + walletKey: process.env.WALLET_KEY, |
| 66 | +}); |
| 67 | +``` |
| 68 | + |
| 69 | +The bot reuses this key, retaining the same address each time it starts. |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +### 2. Automatically generate a key |
| 74 | + |
| 75 | +If you don’t set `WALLET_KEY`, the bot creates a new one at runtime: |
| 76 | + |
| 77 | +```ts |
| 78 | +const agent = await createClient(); |
| 79 | +``` |
| 80 | + |
| 81 | +**Workflow**: |
| 82 | + |
| 83 | +1. A fresh Ethereum private key is generated. |
| 84 | +2. Key details are saved to your `.env` so the bot reuses them in future runs. |
| 85 | + |
| 86 | +--- |
| 87 | + |
| 88 | +### 3. Use a named key |
| 89 | + |
| 90 | +When running multiple bots, each can have a distinct name to avoid overwriting each other’s keys: |
| 91 | + |
| 92 | +```ts |
| 93 | +const agent = await createClient({ name: "botA" }); |
| 94 | +``` |
| 95 | + |
| 96 | +In `.env`, this will be stored as `WALLET_KEY_botA=...` |
| 97 | +**Benefit**: Simplifies managing multiple identities from one project. |
46 | 98 |
|
47 | 99 | ## Web inbox
|
48 | 100 |
|
49 | 101 | Interact with the XMTP protocol using [xmtp.chat](https://xmtp.chat) the official web inbox for developers using the latest version powered by MLS.
|
50 | 102 |
|
51 | 103 | 
|
52 | 104 |
|
53 |
| -> [!WARNING] |
54 |
| -> This React app isn't a complete solution. For example, the list of conversations doesn't update when new messages arrive in existing conversations. |
| 105 | +> To learn more about dev tool visit the [official repo](https://github.com/xmtp/xmtp-js/tree/main/apps/xmtp.chat) |
55 | 106 |
|
56 | 107 | ## Development
|
57 | 108 |
|
|
0 commit comments