|
1 | 1 | # `@ai16z/plugin-cosmos`
|
2 | 2 |
|
3 |
| -This plugin provides actions and providers for interacting with Cosmos compatible chains. |
| 3 | +This plugin provides actions and utilities for interacting with Cosmos-compatible blockchains. |
4 | 4 |
|
5 | 5 | ---
|
6 | 6 |
|
| 7 | +## Development |
| 8 | + |
| 9 | +Prepare Eliza according to [README](../../README.md) |
| 10 | + Add variables required for `@ai16z/plugin-cosmos` : |
| 11 | + ``` |
| 12 | +COSMOS_RECOVERY_PHRASE=your recovery phrase words |
| 13 | +COSMOS_AVAILABLE_CHAINS=chain1,chain2,chain3 |
| 14 | + ``` |
| 15 | + |
| 16 | +Ensure the appropriate environment variables are added for the plugin. If they are correctly configured, the project will run with `@ai16z/plugin-cosmos` |
| 17 | + |
| 18 | +Run Eliza |
| 19 | +``` |
| 20 | +pnpm run dev |
| 21 | +``` |
| 22 | + |
7 | 23 | ## Configuration
|
8 | 24 |
|
9 | 25 | ### Default Setup
|
10 | 26 |
|
11 |
| -### Adding Support for Other Chains |
| 27 | +To start using the plugin, you need to provide your **Cosmos account recovery phrases** and the list of **available chains**. Add the following to your `.env` file: |
| 28 | + |
| 29 | + |
| 30 | +```env |
| 31 | +COSMOS_RECOVERY_PHRASE=your recovery phrase words |
| 32 | +COSMOS_AVAILABLE_CHAINS=chain1,chain2,chain3 |
| 33 | +``` |
| 34 | +Ensure that the chain names in `COSMOS_AVAILABLE_CHAINS` match the identifiers from the [chain-registry](https://github.com/cosmos/chain-registry) library for compatibility. |
| 35 | + |
| 36 | + |
| 37 | +### Using the Cosmos Helper Character |
| 38 | + |
| 39 | +The plugin includes a pre-configured character, `cosmosHelper.character.json`, optimized for Cosmos-related operations. This character enhances interaction by: |
| 40 | + |
| 41 | +- Handling repeated prompts effectively. |
12 | 42 |
|
13 |
| -## Provider |
| 43 | +- Requesting confirmation before executing detected actions. |
| 44 | + |
| 45 | +To use the character, pass it with the `--characters` flag: |
| 46 | + |
| 47 | +```bash |
| 48 | +--characters='../characters/cosmosHelper.character.json' |
| 49 | +``` |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +### Custom chain configuration |
| 54 | +Plugin allows you to pass you custom chain config to `createCosmosPlugin` function invoked in `../agent/src/index`. |
| 55 | + |
| 56 | +Your custom configuration fulfills the interfaces from `chain-registry` |
| 57 | +``` |
| 58 | +import type { assets, chains } from "chain-registry"; |
| 59 | +
|
| 60 | +export interface ICosmosPluginCustomChainData { |
| 61 | + chainData: (typeof chains)[number]; |
| 62 | + assets: (typeof assets)[number]; |
| 63 | +} |
| 64 | +
|
| 65 | +export interface ICosmosPluginOptions { |
| 66 | + customChainData?: ICosmosPluginCustomChainData[]; |
| 67 | +} |
| 68 | +``` |
14 | 69 |
|
15 | 70 | ## Actions
|
16 | 71 |
|
17 |
| -### Transfer |
| 72 | +### Token Transfer |
| 73 | + |
| 74 | +This plugin supports a token transfer action, which allows users to transfer tokens between addresses on Cosmos-compatible blockchains. The action prompts for confirmation to ensure secure execution. |
| 75 | + |
| 76 | +#### Example Prompts |
| 77 | + |
| 78 | +Below are examples of how the transfer action can be initiated and confirmed: |
| 79 | + |
| 80 | +**Example** |
| 81 | + |
| 82 | +1. User input: |
| 83 | + |
| 84 | +``` |
| 85 | +Make transfer 0.0001 ATOM to cosmos1nk3uuw6zt5t5aqw5fvujkd54sa4uws9xv465ad on cosmoshubtestnet. |
| 86 | +``` |
| 87 | + |
| 88 | +2. Plugin response: |
| 89 | + |
| 90 | +``` |
| 91 | +Do you confirm the transfer action? |
| 92 | +``` |
| 93 | + |
| 94 | +3. User confirmation: |
| 95 | + |
| 96 | +``` |
| 97 | +Yes |
| 98 | +``` |
| 99 | + |
| 100 | +4. Action executed. |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +## Contribution |
| 105 | + |
| 106 | +The plugin includes comprehensive tests. Before submitting any pull requests, ensure all tests pass. |
18 | 107 |
|
19 | 108 | ### Running Tests
|
20 | 109 |
|
21 |
| -Navigate to the `plugin-cosmos` directory and run: |
| 110 | +Navigate to the `plugin-cosmos` directory and execute: |
22 | 111 |
|
23 | 112 | ```bash
|
24 |
| -pnpm test |
| 113 | +pnpm test |
25 | 114 | ```
|
| 115 | + |
| 116 | +--- |
| 117 | + |
| 118 | +This plugin simplifies Cosmos blockchain interactions and enhances productivity with its tailored features. Happy building! |
0 commit comments