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: rooch plugin for eliza #2308

Draft
wants to merge 26 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1339414
feat: init rooch plugin
yubing744 Jan 15, 2025
e851d8b
feat: update plugin-rooch/README.md
yubing744 Jan 15, 2025
570de84
feat: define ICharacterLoader and implement roochCharacterLoader
yubing744 Jan 15, 2025
e0ff8b9
feat: impl ICharacterConfigLoader
yubing744 Jan 16, 2025
17b2213
fix: fix depends
yubing744 Jan 16, 2025
d515987
Update README.md
jolestar Jan 16, 2025
cbe16fe
fix typo
jolestar Jan 16, 2025
21621bb
feat: add test case for foc_eliza decode
yubing744 Jan 17, 2025
4d1ae6f
Merge branch 'eliza-plugin-rooch' of github.com:rooch-network/eliza i…
yubing744 Jan 17, 2025
9ed8c53
fix: fix unit test for decodeCharacterData
yubing744 Jan 18, 2025
e1e931c
feat: ok for start agent with rooch plugin
yubing744 Jan 18, 2025
54c32b8
feat: ok for load character from rooch foc_eliza character object
yubing744 Jan 19, 2025
fcc876f
feat: merge from develop
yubing744 Jan 19, 2025
350aeb1
feat: update agent index with loadCharacterFromLoaders
yubing744 Jan 19, 2025
fbef123
feat: recover remove deps
yubing744 Jan 19, 2025
92e3030
fix: fixbug for character not found
yubing744 Jan 21, 2025
fca7ddf
feat: parse BITCOIN_WIF_PRIVATE_KEY as ParsedKeypair
yubing744 Jan 22, 2025
e190eae
feat: add unit test for parseKeypair
yubing744 Jan 23, 2025
f814e53
feat: impl assets provider
yubing744 Jan 23, 2025
a262998
feat: add unit test for assetsProvider.ts
yubing744 Feb 5, 2025
3de410d
feat: impl transfer coin
yubing744 Feb 5, 2025
587389d
feat: ok for add unit test for transferCoin action
yubing744 Feb 5, 2025
f1a367d
feat: merge from devlep
yubing744 Feb 6, 2025
aff5be7
feat: restore agent update
yubing744 Feb 6, 2025
de69832
feat: fix review issues
yubing744 Feb 6, 2025
ca3aacb
fix: fix self review issues
yubing744 Feb 6, 2025
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
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,10 @@ PINATA_API_SECRET= # Pinata API secret
SUI_PRIVATE_KEY= # Sui Mnemonic Seed Phrase (`sui keytool generate ed25519`) , Also support `suiprivatekeyxxxx` (sui keytool export --key-identity 0x63)
SUI_NETWORK= # must be one of mainnet, testnet, devnet, localnet

# Rooch
BITCOIN_PRIVATE_KEY= # Bitcoin WIP Private key
ROOCH_NETWORK= # must be one of mainnet, testnet, devnet, localnet

# Mina Settings
MINA_PRIVATE_KEY= # Mina Mnemonic Seed Phrase: https://docs.minaprotocol.com/using-mina/install-a-wallet
MINA_NETWORK=devnet # must be one of mainnet, testnet, devnet, localnet
Expand Down
1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"@elizaos/plugin-starknet": "workspace:*",
"@elizaos/plugin-story": "workspace:*",
"@elizaos/plugin-sui": "workspace:*",
"@elizaos/plugin-rooch": "workspace:*",
"@elizaos/plugin-sgx": "workspace:*",
"@elizaos/plugin-iq6900": "workspace:*",
"@elizaos/plugin-tee": "workspace:*",
Expand Down
2 changes: 2 additions & 0 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ import { squidRouterPlugin } from "@elizaos/plugin-squid-router";
import { stargazePlugin } from "@elizaos/plugin-stargaze";
import { storyPlugin } from "@elizaos/plugin-story";
import { suiPlugin } from "@elizaos/plugin-sui";
import { roochPlugin } from "@elizaos/plugin-rooch";
import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
import { teeLogPlugin } from "@elizaos/plugin-tee-log";
import { teeMarlinPlugin } from "@elizaos/plugin-tee-marlin";
Expand Down Expand Up @@ -1176,6 +1177,7 @@ export async function createAgent(
getSecret(character, "TON_PRIVATE_KEY") ? tonPlugin : null,
getSecret(character, "THIRDWEB_SECRET_KEY") ? thirdwebPlugin : null,
getSecret(character, "SUI_PRIVATE_KEY") ? suiPlugin : null,
getSecret(character, "BITCOIN_PRIVATE_KEY") ? roochPlugin : null,
getSecret(character, "STORY_PRIVATE_KEY") ? storyPlugin : null,
getSecret(character, "SQUID_SDK_URL") &&
getSecret(character, "SQUID_INTEGRATOR_ID") &&
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-rooch/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*

!dist/**
!package.json
!readme.md
!tsup.config.ts
162 changes: 162 additions & 0 deletions packages/plugin-rooch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# @elizaos/plugin-rooch

Core Rooch plugin for Eliza OS that provides essential services and actions for wallet management and token operations on the Rooch network.

## Overview

This plugin provides functionality to:
- Transfer tokens between wallets (currently supporting RGas for GAS consumption)
- Query wallet balances and portfolio values
- Manage wallet interactions with the Rooch network

## Installation

```bash
npm install @elizaos/plugin-rooch
```

## Configuration

The plugin requires the following environment variables:

```env
BITCOIN_PRIVATE_KEY=bitcoin_wip_private_key
ROOCH_NETWORK=mainnet|testnet|devnet|localnet
```

## Usage

Import and register the plugin in your Eliza configuration:

```typescript
import { roochPlugin } from "@elizaos/plugin-rooch";

export default {
plugins: [roochPlugin],
// ... other configuration
};
```

## Features

### Send RGas

Transfer RGas (Rooch network gas token) to another address:

```typescript
// Example conversation
User: "Send 10 RGas to 0x4f2e63be8e7fe287836e29cde6f3d5cbc96eefd0c0e3f3747668faa2ae7324b0"
Assistant: "I'll send 10 RGas now..."
```

### Check Wallet Balance

Query wallet balance and portfolio value:

```typescript
// Example conversation
User: "What's my wallet balance?"
Assistant: "Your wallet contains 100 RGas..."
```

## API Reference

### Actions

- `SEND_COIN`: Transfer RGas to another address
- `TRANSFER_COIN`: Alias for SEND_COIN
- `SEND_RGAS`: Alias for SEND_COIN
- `PAY`: Alias for SEND_COIN

### Providers

- `assetsProvider`: Manages wallet interactions with the Rooch network, including balance queries and portfolio tracking

## Development

### Building

```bash
npm run build
```

### Testing

```bash
npm run test
```

## Dependencies

- `@roochnetwork/rooch-sdk`: Core Rooch blockchain interaction library
- `bignumber.js`: Precise number handling
- `node-cache`: Caching implementation
- Other standard dependencies listed in package.json

## Future Enhancements

The following features and improvements are planned for future releases:

1. **Transaction Management**
- Batch transaction processing
- Transaction simulation
- Gas optimization strategies
- Custom transaction builders
- Advanced error handling

2. **Wallet Integration**
- Multi-wallet support
- Hardware wallet integration
- Social recovery options
- Account abstraction
- Transaction history tracking

3. **Smart Contract Features**
- Contract deployment tools
- Move module templates
- Testing framework
- Upgrade management
- Security analysis

4. **Token Operations**
- Batch token transfers
- Token metadata handling
- Custom token standards
- Collection management

5. **Developer Tools**
- Enhanced debugging
- CLI improvements
- Documentation generator
- Integration templates
- Performance monitoring

We welcome community feedback and contributions to help prioritize these enhancements.

## Contributing

Contributions are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information.

## Credits

This plugin integrates with and builds upon several key technologies:

- [Rooch Network](https://rooch.network): The Bitcoin Application Layer features MoveVM and Bitcoin staking.
- [@roochnetwork/rooch-sdk](https://www.npmjs.com/package/@roochnetwork/rooch-sdk): Official Rooch SDK
- [bignumber.js](https://github.com/MikeMcl/bignumber.js/): Precise number handling
- [node-cache](https://www.npmjs.com/package/node-cache): Caching implementation

Special thanks to:
- The Rooch team for developing the Rooch network
- The Rooch Developer community
- The Rooch SDK maintainers
- The Eliza community for their contributions and feedback

For more information about Rooch network capabilities:
- [Rooch Documentation](https://rooch.network/learn/overview)
- [Rooch Developer Portal](https://rooch.network/learn/overview)
- [Rooch GitHub Repository](https://github.com/rooch-network)

## License

This plugin is part of the Eliza project. See the main project repository for license information.
3 changes: 3 additions & 0 deletions packages/plugin-rooch/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslintGlobalConfig from "../../eslint.config.mjs";

export default [...eslintGlobalConfig];
23 changes: 23 additions & 0 deletions packages/plugin-rooch/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@elizaos/plugin-rooch",
"version": "0.1.5-alpha.5",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"dependencies": {
"@elizaos/core": "workspace:*",
"@roochnetwork/rooch-sdk": "^0.2.9",
"@types/bs58check": "^2.1.2"
},
"devDependencies": {
"@types/node": "^20.0.0",
"tsup": "8.3.5"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"lint": "eslint --fix --cache .",
"test": "vitest run",
"tool:gen-bitcoin-wallet": "node ./tools/gen_bitcoin_wallet.js"
}
}
Loading