Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Cronos Evm #2585

Merged
merged 4 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
257 changes: 257 additions & 0 deletions packages/plugin-cronos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
# @elizaos/plugin-cronos

Cronos plugin for Eliza, extending the EVM plugin functionality.

## Supported Networks

### Mainnet
- Cronos Mainnet (Chain ID: 25)
- RPC Endpoint: https://evm.cronos.org/
- Explorer: https://explorer.cronos.org/
- Native Token: CRO

### Testnet
- Cronos Testnet 3 (Chain ID: 338)
- RPC Endpoint: https://evm-t3.cronos.org/
- Explorer: https://cronos.org/explorer/testnet3
- Native Token: TCRO

## Installation

```bash
pnpm add @elizaos/plugin-cronos
```

## Usage

### Basic Setup
```typescript
import { cronosPlugin } from "@elizaos/plugin-cronos";

// Use the plugin in your Eliza configuration
const config = {
plugins: [cronosPlugin],
// ... rest of your config
};
```

### Character Configuration Guide

Create a `your-character.character.json` file with the following structure:

```json
{
"name": "YourCharacterName",
"plugins": ["@elizaos/plugin-cronos"],
"clients": ["telegram"],
"modelProvider": "openai",
"settings": {
"secrets": {},
"chains": {
"evm": ["cronos", "cronosTestnet"]
}
},
"system": "Primary function is to execute token transfers and check balances on Cronos chain.",
"actions": {
"SEND_TOKEN": {
"enabled": true,
"priority": 1,
"force": true,
"schema": {
"type": "object",
"properties": {
"fromChain": {
"type": "string",
"description": "The chain to execute the transfer on",
"enum": ["cronos", "cronosTestnet"]
},
"toAddress": {
"type": "string",
"description": "The recipient's wallet address",
"pattern": "^0x[a-fA-F0-9]{40}$"
},
"amount": {
"type": "string",
"description": "The amount of tokens to transfer",
"pattern": "^[0-9]*(\\.[0-9]+)?$"
}
},
"required": ["fromChain", "toAddress", "amount"]
},
"triggers": [
"send * CRO to *",
"transfer * CRO to *"
],
"examples": [
{
"input": "Send 0.1 CRO to 0x...",
"output": {
"fromChain": "cronos",
"toAddress": "0x...",
"amount": "0.1"
}
}
]
},
"CHECK_BALANCE": {
"enabled": true,
"priority": 1,
"force": true,
"schema": {
"type": "object",
"properties": {
"chain": {
"type": "string",
"description": "The chain to check balance on",
"enum": ["cronos", "cronosTestnet"]
}
},
"required": ["chain"]
},
"triggers": [
"check balance",
"show balance",
"what's my balance",
"how much CRO do I have",
"check balance on *",
"show balance on *"
],
"examples": [
{
"input": "check balance",
"output": {
"chain": "cronos"
}
},
{
"input": "what's my balance on testnet",
"output": {
"chain": "cronosTestnet"
}
}
]
}
},
"messageExamples": [
[
{
"user": "{{user1}}",
"content": {
"text": "Send 100 CRO to 0x..."
}
},
{
"user": "YourCharacterName",
"content": {
"text": "Processing token transfer...",
"action": "SEND_TOKEN"
}
}
],
[
{
"user": "{{user1}}",
"content": {
"text": "What's my balance?"
}
},
{
"user": "YourCharacterName",
"content": {
"text": "Checking your balance...",
"action": "CHECK_BALANCE"
}
}
]
]
}
```

#### Key Configuration Fields:

1. **Basic Setup**
- `name`: Your character's name
- `plugins`: Include `@elizaos/plugin-cronos`
- `clients`: Supported client platforms

2. **Chain Settings**
- Configure both mainnet and testnet in `settings.chains.evm`
- Available options: `"cronos"` (mainnet) and `"cronosTestnet"`

3. **Action Configuration**
- `SEND_TOKEN`: Action for token transfers
- `CHECK_BALANCE`: Action for checking wallet balance
- `schema`: Defines the required parameters for each action
- `triggers`: Phrases that activate the actions
- `examples`: Sample inputs and outputs

4. **Message Examples**
- Provide example interactions
- Show how actions are triggered
- Demonstrate expected responses

### Action Examples
```
// Send tokens on mainnet
"Send 0.1 CRO to 0x..." use mainnet

// Send tokens on testnet
"Send 0.1 TCRO to 0x..." use testnet

// Check balance on mainnet
"check balance"
"what's my balance"
"how much CRO do I have"

// Check balance on testnet
"check balance on testnet"
"what's my balance on testnet"
```

## Features

- All standard EVM functionality inherited from @elizaos/plugin-evm
- Preconfigured for both Cronos Mainnet and Testnet
- Native CRO/TCRO token support
- Automated token transfer actions
- Balance checking functionality
- Built-in chain configuration

## Environment Variables

Required environment variable for transactions:

```env
# Wallet private key (Required, must start with 0x)
CRONOS_PRIVATE_KEY=0x...
```

### Security Warnings ⚠️

- **NEVER** commit private keys to version control
- **NEVER** share private keys with anyone
- **ALWAYS** use environment variables or secure key management
- Use separate keys for mainnet and testnet
- Monitor your wallet for unauthorized transactions

### Setup

1. Create `.env` file:
```env
CRONOS_PRIVATE_KEY=0x... # Mainnet
```

2. For testnet development, use `.env.local`:
```env
CRONOS_PRIVATE_KEY=0x... # Testnet only
```

3. Add to `.gitignore`:
```
.env
.env.*
```

## License

MIT
33 changes: 33 additions & 0 deletions packages/plugin-cronos/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@elizaos/plugin-cronos",
"version": "0.0.1",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"@elizaos/source": "./src/index.ts",
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"files": [
"dist"
],
"scripts": {
"build": "tsup --format esm --dts"
},
"dependencies": {
"@elizaos/core": "workspace:*",
"node-cache": "^5.1.2",
"viem": "^2.0.0"
},
"devDependencies": {
"tsup": "^8.0.1",
"typescript": "^5.3.3"
}
}
Loading
Loading