Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

@elizaos/plugin-para

A seamless integration between Para wallet infrastructure and Eliza OS, enabling autonomous agents to manage user wallets and transactions.

npm versionnpm downloadsbundle size

Features

  • 🔐 Full Para wallet integration with Eliza agents
  • 💰 EVM-based transaction support using Viem
  • 📝 Message signing capabilities
  • 💼 Pre-generated wallet support
  • 🔄 Seamless wallet claiming process
  • 🛡️ Secure user share management
  • 🌐 Multi-chain support (Ethereum, Polygon, Arbitrum, etc.)
  • 📋 Built-in wallet status monitoring
  • 🤖 Auto-configuration with Eliza agents
  • 📱 Session management for persistent authentication

Installation

You can install the plugin using your preferred package manager:

# npm
npm install @elizaos/plugin-para
# pnpm
pnpm add @elizaos/plugin-para
# yarn
yarn add @elizaos/plugin-para
# bun
bun add @elizaos/plugin-para

Configuration

  1. Add required environment variables to your .env file:
# Para ConfigurationPARA_API_KEY=your-para-api-keyPARA_ENV=production
  1. Register the plugin in your Eliza character configuration:
import{paraPlugin}from'@elizaos/plugin-para';exportconstcharacterConfig={// ... other configplugins: [paraPlugin],settings: {secrets: {PARA_API_KEY: process.env.PARA_API_KEY,PARA_ENV: process.env.PARA_ENV||'production'}}};

Usage

The plugin adds several capabilities to your Eliza agent:

Creating Wallets

// The agent can create wallets in response to user requestsawaitruntime.triggerAction("CREATE_PARA_WALLET",{type: "EVM"});

Pre-generating Wallets

// Create a wallet for a user before they sign upawaitruntime.triggerAction("CREATE_PREGEN_WALLET",{pregenIdentifier: "user@example.com",pregenIdentifierType: "EMAIL"});

Signing Messages

// Sign a message with a user's walletawaitruntime.triggerAction("SIGN_PARA_MESSAGE",{walletId: "wallet-id",message: "Hello, World!"});

Signing Transactions

// Sign and submit an EVM transactionawaitruntime.triggerAction("SIGN_PARA_TRANSACTION",{walletId: "wallet-id",transaction: {to: "0x1234567890123456789012345678901234567890",value: "0.01"},chainId: "1"// Ethereum mainnet});

Claiming Pre-generated Wallets

// Users can claim their pre-generated walletsawaitruntime.triggerAction("CLAIM_PARA_WALLET",{pregenIdentifier: "user@example.com",pregenIdentifierType: "EMAIL"});

Checking Wallet Status

// Get current wallet status through the providerconstwalletInfo=awaitruntime.getContextFromProvider("paraWalletProvider");

Actions

The plugin provides the following actions:

ActionDescription
CREATE_PARA_WALLETCreates a new Para wallet
CREATE_PREGEN_WALLETCreates a pre-generated wallet associated with an identifier
CLAIM_PARA_WALLETClaims a pre-generated wallet
SIGN_PARA_MESSAGESigns a message using a Para wallet
SIGN_PARA_TRANSACTIONSigns and submits a transaction using a Para wallet
UPDATE_PREGEN_IDENTIFIERUpdates the identifier for a pre-generated wallet

Providers

Available providers for context and status:

ProviderDescription
paraWalletProviderProvides current wallet information and status

Services

The plugin registers the following services in the Eliza runtime:

ServiceDescription
ParaWalletServiceCore service handling Para SDK integration

Viem Integration

The plugin uses Viem for Ethereum transactions, offering:

  • 🚀 Modern and efficient transaction handling
  • 🔧 Type-safe API for Ethereum interactions
  • ⚡ Multi-chain support out of the box
  • 🔄 Compatible with the Para Viem connector
// Example of transaction handling with Viemawaitruntime.triggerAction("SIGN_PARA_TRANSACTION",{walletId: "wallet-id",transaction: {to: "0x1234567890123456789012345678901234567890",value: "0.05",data: "0x..."// Optional contract interaction data},chainId: "137"// Polygon});

Session Management

The plugin implements Para's session management for maintaining authenticated states:

constparaService=runtime.getService<ParaWalletService>(ExtendedServiceType.PARA_WALLET);// Check if session is activeconstisActive=awaitparaService.isSessionActive();// Keep session aliveif(isActive){awaitparaService.keepSessionAlive();}else{awaitparaService.refreshSession();}

User Share Management

Secure handling of user shares for pre-generated wallets:

// Get user share after wallet creationconst{ wallet, userShare }=awaitparaService.createPregenWallet({pregenIdentifier: "user@example.com",pregenIdentifierType: "EMAIL"});// Store user share securelyawaitsecureStorage.set(`user-share-${wallet.id}`,userShare);// Restore user share when neededawaitparaService.setUserShare({userShare: awaitsecureStorage.get(`user-share-${walletId}`)});

Error Handling

The plugin implements comprehensive error handling following Eliza's patterns:

try{awaitruntime.triggerAction("SIGN_PARA_TRANSACTION",params);}catch(error){if(errorinstanceofTransactionReviewDenied){// Handle user denialconsole.log("User denied the transaction");}elseif(errorinstanceofTransactionReviewTimeout){// Handle timeoutconsole.log("Transaction review timed out",error.transactionReviewUrl);}else{// Handle other errorsconsole.error("Transaction error:",error);}}

Multi-Chain Support

The plugin supports a variety of EVM-compatible networks:

Chain IDNetwork
1Ethereum Mainnet
11155111Sepolia Testnet
137Polygon
42161Arbitrum

Additional networks can be added by extending the chain configuration.

Best Practices

  1. Security

    • Store API keys securely in environment variables
    • Implement proper user authentication before wallet operations
    • Use secure storage for user shares
    • Follow Para's recommendations for session management
  2. Error Handling

    • Implement proper error handling for all wallet operations
    • Handle transaction rejections and timeouts gracefully
    • Provide clear feedback to users when operations fail
    • Log errors appropriately for debugging
  3. Performance

    • Keep track of session status to avoid unnecessary refreshes
    • Implement proper caching for wallet information
    • Use appropriate gas parameters for transactions
    • Handle network congestion scenarios with retry logic
  4. User Experience

    • Guide users through the wallet creation process
    • Provide clear status updates during operations
    • Implement proper loading states during transaction signing
    • Give feedback on transaction progress and confirmations

Contributing

We welcome contributions! Please see our Contributing Guide for details.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License - see the LICENSE file for details.

Related

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages