|
| 1 | +# `@ai16z/plugin-evm` |
| 2 | + |
| 3 | +This plugin provides actions and providers for interacting with EVM-compatible chains. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Configuration |
| 8 | + |
| 9 | +### Default Setup |
| 10 | + |
| 11 | +By default, **Ethereum mainnet** is enabled. To use it, simply add your private key to the `.env` file: |
| 12 | + |
| 13 | +```env |
| 14 | +EVM_PRIVATE_KEY=your-private-key-here |
| 15 | +``` |
| 16 | + |
| 17 | +### Adding Support for Other Chains |
| 18 | + |
| 19 | +To enable support for additional chains, add them to the character config like this: |
| 20 | + |
| 21 | +```json |
| 22 | +"settings": { |
| 23 | + "chains": { |
| 24 | + "evm": [ |
| 25 | + "base", "arbitrum", "iotex" |
| 26 | + ] |
| 27 | + } |
| 28 | +} |
| 29 | +``` |
| 30 | + |
| 31 | +Note: The chain names must match those in the viem/chains. |
| 32 | + |
| 33 | +### Custom RPC URLs |
| 34 | + |
| 35 | +By default, the RPC URL is inferred from the `viem/chains` config. To use a custom RPC URL for a specific chain, add the following to your `.env` file: |
| 36 | + |
| 37 | +```env |
| 38 | +ETHEREUM_PROVIDER_<CHAIN_NAME>=https://your-custom-rpc-url |
| 39 | +``` |
| 40 | + |
| 41 | +**Example usage:** |
| 42 | + |
| 43 | +```env |
| 44 | +ETHEREUM_PROVIDER_IOTEX=https://iotex-network.rpc.thirdweb.com |
| 45 | +``` |
| 46 | + |
| 47 | +#### Custom RPC for Ethereum Mainnet |
| 48 | + |
| 49 | +To set a custom RPC URL for Ethereum mainnet, use: |
| 50 | + |
| 51 | +```env |
| 52 | +EVM_PROVIDER_URL=https://your-custom-mainnet-rpc-url |
| 53 | +``` |
| 54 | + |
| 55 | +## Provider |
| 56 | + |
| 57 | +The **Wallet Provider** initializes with the **first chain in the list** as the default (or Ethereum mainnet if none are added). It: |
| 58 | + |
| 59 | +- Provides the **context** of the currently connected address and its balance. |
| 60 | +- Creates **Public** and **Wallet clients** to interact with the supported chains. |
| 61 | +- Allows adding chains dynamically at runtime. |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +## Actions |
| 66 | + |
| 67 | +### Transfer |
| 68 | + |
| 69 | +Transfer tokens from one address to another on any EVM-compatible chain. Just specify the: |
| 70 | + |
| 71 | +- **Amount** |
| 72 | +- **Chain** |
| 73 | +- **Recipient Address** |
| 74 | + |
| 75 | +**Example usage:** |
| 76 | + |
| 77 | +```bash |
| 78 | +Transfer 1 ETH to 0xRecipient on arbitrum. |
| 79 | +``` |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## Contribution |
| 84 | + |
| 85 | +The plugin contains tests. Whether you're using **TDD** or not, please make sure to run the tests before submitting a PR. |
| 86 | + |
| 87 | +### Running Tests |
| 88 | + |
| 89 | +Navigate to the `plugin-evm` directory and run: |
| 90 | + |
| 91 | +```bash |
| 92 | +pnpm test |
| 93 | +``` |
0 commit comments