Back to Eliza

@elizaos/plugin-wallet — EVM chain

plugins/plugin-wallet/src/chains/evm/README.md

2.0.14.5 KB
Original Source

@elizaos/plugin-wallet — EVM chain

EVM chain implementation inside @elizaos/plugin-wallet. Provides token transfers, cross-chain bridging, token swaps via LiFi, and DAO governance helpers across all major EVM-compatible chains.

Features

  • Multi-chain Support: Ethereum, Base, Arbitrum, Optimism, Polygon, and 10+ more chains
  • Native Token Transfers: Send ETH, MATIC, BNB, and other native gas tokens
  • ERC20 Token Transfers: Send any ERC20 token
  • Cross-chain Bridging: Bridge tokens between chains via LiFi
  • Token Swaps: Exchange tokens on supported DEXs
  • DAO Governance: Propose, vote, queue, and execute proposals
  • Strong Typing: Branded types with Zod schemas, fail-fast validation

Supported Chains

ChainIDNative Token
Ethereum Mainnet1ETH
Sepolia (testnet)11155111ETH
Base8453ETH
Base Sepolia84532ETH
Arbitrum One42161ETH
Optimism10ETH
Polygon137MATIC
Avalanche C-Chain43114AVAX
BNB Smart Chain56BNB
Gnosis100xDAI
Fantom250FTM
Linea59144ETH
Scroll534352ETH
zkSync Era324ETH
Radius Network723487RUSD
Radius Testnet72344RUSD

Installation

bash
bun add @elizaos/plugin-wallet
# or
npm install @elizaos/plugin-wallet

Quick Start

typescript
import { evmPlugin, EvmService } from "@elizaos/plugin-wallet";

// Add to your agent
const agent = createAgent({
  plugins: [evmPlugin],
});

// Or use the service directly
const service = new EvmService();
await service.initialize(runtime);

// Get wallet info
const address = service.getAddress();
const balance = await service.getBalance("mainnet");

Strong Typing (Zod + Branded Types)

typescript
import { ZAddress, ZTransferParams } from "@elizaos/plugin-wallet";

// Validated at runtime
const address = ZAddress.parse("0x1234..."); // Throws if invalid
const params = ZTransferParams.parse({
  fromChain: "mainnet",
  toAddress: "0x...",
  amount: "1.0",
});

Directory Structure

plugins/plugin-wallet/src/chains/evm/
├── actions/              # Transfer, swap, bridge, governance actions
├── providers/            # EVM wallet provider
├── types/                # Branded types and Zod schemas
├── contracts/            # ABI bindings
├── prompts/              # Action prompt specs
├── generated/            # Auto-generated docs
├── service.ts            # EvmService entry
├── rpc-providers.ts      # Provider routing (Alchemy / Infura / Ankr / elizacloud)
└── index.ts              # Module entry

Configuration

Environment VariableRequiredDescription
EVM_PRIVATE_KEYYesPrivate key for the agent's wallet (hex, starting with 0x)
EVM_RPC_PROVIDERNoDefault RPC provider preference: alchemy / infura / ankr / elizacloud
ALCHEMY_API_KEY / INFURA_API_KEY / ANKR_API_KEYNoAPI keys for the corresponding RPC provider
ETHEREUM_PROVIDER_<CHAIN>NoCustom RPC URL override (e.g. ETHEREUM_PROVIDER_BASE, ETHEREUM_PROVIDER_ARBITRUM)
TEE_MODENoTrusted Execution Environment mode (OFF / ON)
WALLET_SECRET_SALTNoSalt for TEE-derived wallet keypair
SEPOLIA_RPC_URL / BASE_SEPOLIA_RPC_URLNoCustom testnet RPC URLs

License

MIT — see LICENSE.