LogoLogo
  • JuliaOS Documentation Hub
  • About JuliaOS
    • Mission & Vision
    • Features and Capabilities
    • Roadmap
    • Tokenomics
  • Ecosystem
    • Overview
  • Partners
    • Heurist
    • Fetch.ai
    • Soulgraph
    • cheqd.io
    • Aethir
    • Anyone
    • TensorLabs
    • Hashpower
  • Technology
    • Overview
    • Open Source
      • Modular Framework
      • CLI Mode
    • AI Platform
      • Dashboard
      • Agent Management
      • Swarm Management
      • Marketplace
      • Mining
    • LLM
    • Launchpad
    • Robotics & IOT
      • SwarmIOT
      • Modular AI with Robotics
        • J3OS MiniLLM
          • 🔧 Use Cases
  • Technical
    • Overview
    • Developer Hub
      • Getting Started
        • Installation Guide
          • Github Guide
        • Basic Concepts
        • Quick Start Guide
          • Handling secrets
        • Examples and Use
          • Example: Using the Trading Functionality
          • Example: Using the Benchmarking Feature
          • Example: Multi-Agent Swarm Coordination
          • Example: Using the Python Wrapper for LLM Integration
          • Example: Using Cross-Chain Bridges
          • Example: Creating and Running a Swarm Optimization
          • Page 4
      • Best Practices
        • Performance Tuning
        • Agent/Swarm Design Patterns
        • Best Practices & Patterns
        • Security Best Practices
      • CLI
        • JuliaOS CLI Interface
        • Agent Management (CLI)
        • CLI Configuration
        • Cross-Chain Hub (CLI)
        • Swarm Management (CLI)
        • CLI Troubleshooting
        • Wallet Management (CLI)
      • Framework SDK
        • Modules
          • Bridge
          • Agents Module
          • Dex
          • Swarms Module
          • Wallet
        • Python Wrapper
          • LangChain Integration
          • Python Wrapper
      • Contributing Guide
      • Extending JuliaOS
      • Development Setup & Conventions
      • Testing & Debugging
      • Troubleshooting
    • Architecture
      • High Level JuliaOS
      • CLI <-> Backend Communication
      • Data Storage Architecture
      • Framework Internals
      • Architecture Deep Dive
        • Architectual Notes
    • Concepts
      • Core Features & Concepts
      • Agents
        • Agent Skills & Specializations
      • Swarms
      • Neural Networks
      • Blockchains & Chains
      • Bridges (Cross-Chain)
      • Integrations
        • Google ADK
        • LLMs
        • Price Feed
        • DEX Integration
      • Storage
      • Trading Capabilities
      • Use Cases
      • Wallets
      • Portfolio Optimization
  • Research
    • JuliaOS Research
  • API Documentation
    • API Reference
      • API Reference: Julia Backend Commands
      • API Reference: CLI Commands
      • API Reference: Node.js API
      • API Reference: Python API
      • API Reference
  • Community
    • Community & Support
  • FAQ
    • General
    • Technical
    • Community
Powered by GitBook
On this page
  • Concept
  • Wallet Architecture in JuliaOS
  • 1. Client-Side Wallet Management (@juliaos/wallets package)
  • 2. Backend Wallet Management (Wallet.jl module)
  • Supported Wallet Types
  • Client-Side Wallets
  • Backend-Managed Wallets
  • Supported Chains
  • Implementation Details
  • Key Management
  • Transaction Signing
  • Security Measures
  • Using Wallets
  • Client-Side Wallets (JavaScript/TypeScript)
  • Backend Wallets (Julia)
  • Python Interface
  • CLI Usage
  • Integration with Agents and Swarms
  • Security Best Practices
  • Future Enhancements
Export as PDF
  1. Technical
  2. Concepts

Wallets

JuliaOS provides comprehensive wallet integration features, allowing users and agents to interact with various blockchain networks securely and efficiently.

  • Multi-Chain Support: Comprehensive wallet support for multiple blockchain networks including Ethereum, Polygon, and Solana.

  • Multiple Providers: Integration with various wallet providers including MetaMask, Phantom, and Rabby.

  • Private Key Management: Secure private key management with encryption and key derivation.

  • Hardware Wallet Support: Integration with hardware wallets for enhanced security.

  • Transaction Signing: Robust transaction signing with support for different transaction types and formats.

  • Balance Tracking: Real-time balance tracking across multiple chains and tokens.

  • Address Management: Management of multiple addresses with labeling and organization features.

  • Transaction History: Comprehensive transaction history with filtering and search capabilities.

  • Gas Estimation: Accurate gas estimation for EVM transactions with fee optimization.

  • Nonce Management: Automatic nonce management to prevent transaction failures.

Concept

In the context of blockchains, a "wallet" is software or hardware that manages a user's cryptographic keys (public and private keys). The public key derives the blockchain address (where assets are held), and the private key is required to authorize transactions (sending assets, interacting with contracts).

Wallet Architecture in JuliaOS

JuliaOS implements a dual-layer wallet architecture to balance security, flexibility, and autonomy:

1. Client-Side Wallet Management (@juliaos/wallets package)

  • Purpose: Allow end-users to connect their existing browser extension wallets (like Metamask, Phantom, Rabby)

  • Implementation: Fully implemented in TypeScript/JavaScript

  • Functionality: Provides a WalletManager class that handles:

    • Detecting and connecting to installed browser wallets

    • Retrieving the user's connected address and current chain

    • Requesting the wallet to sign messages

    • Requesting the wallet to sign and send transactions (private keys never leave the user's wallet)

    • Handling events like account or chain changes

    • Multi-chain support for different wallet types

  • Security: High security as users maintain control of their private keys within their own wallet software

  • Use Case: User-initiated actions, managing personal portfolios connected to JuliaOS

2. Backend Wallet Management (Wallet.jl module)

  • Purpose: Allow the JuliaOS backend or automated agents to manage wallets directly

  • Implementation: Fully implemented in Julia with comprehensive security measures

  • Functionality: Includes functions for:

    • Creating and importing wallets (from private key, seed phrase, keystore)

    • Securely storing encrypted private keys

    • Signing transactions for multiple chains

    • Managing wallet balances and transaction history

    • HD wallet derivation and management

    • Hardware wallet integration

  • Security: Implements strong encryption (AES-256), secure key storage, and optional hardware wallet support

  • Use Case: Automated agent operations, system-controlled accounts, trading bots

Supported Wallet Types

JuliaOS supports multiple wallet types to meet different security and usability requirements:

Client-Side Wallets

  • Browser Extension Wallets:

    • Metamask and other EVM-compatible wallets (Rabby, Frame, etc.)

    • Phantom for Solana

    • Keplr for Cosmos ecosystem

    • Rabby for multi-chain support

    • WalletConnect for mobile wallet integration

  • Features:

    • Non-custodial (user controls private keys)

    • Easy connection via browser extensions

    • Familiar user experience

    • Transaction confirmation in the wallet UI

Backend-Managed Wallets

  • Local Encrypted Wallets:

    • Private keys stored locally with AES-256 encryption

    • Password protection with PBKDF2 key derivation

    • Support for keystore file import/export

  • HD Wallets:

    • BIP-39 mnemonic phrase generation and recovery

    • BIP-32/44 derivation paths for multiple chains

    • Account and address management

  • Hardware Wallets:

    • Ledger integration (Nano S, Nano X)

    • Trezor integration (Model T, Model One)

    • Transaction signing on device

    • Address verification

  • In-Memory Wallets:

    • Temporary wallets for testing or specific operations

    • Keys never persisted to disk

Supported Chains

JuliaOS wallet functionality extends to multiple blockchain networks:

  • EVM-Compatible Chains:

    • Ethereum (mainnet and testnets)

    • Layer 2 solutions (Arbitrum, Optimism, Base, Polygon)

    • Alternative EVM chains (BSC, Avalanche, Fantom)

  • Solana:

    • Mainnet, Devnet, Testnet

    • SPL token support

    • Program interaction

  • Experimental Support:

    • Aptos

    • Sui

    • Cosmos ecosystem (via Keplr)

Implementation Details

Key Management

  • Encryption: AES-256 for stored keys

  • Key Derivation: PBKDF2 with high iteration count

  • Storage: Encrypted keystore files compatible with standard formats

  • Memory Protection: Secure memory handling to prevent key exposure

Transaction Signing

  • EVM Chains:

    • Support for legacy, EIP-1559, and EIP-2930 transactions

    • EIP-712 typed data signing

    • Personal message signing

  • Solana:

    • Transaction and message signing

    • Versioned transaction support

    • Partial signing for multi-signatures

Security Measures

  • Encryption at Rest: All private keys are encrypted when stored

  • Secure Input: Password input is handled securely

  • Timeout: Automatic session timeout for decrypted keys

  • Audit Logging: All wallet operations are logged (without sensitive data)

  • Hardware Security: Option to use hardware wallets for critical operations

Using Wallets

Client-Side Wallets (JavaScript/TypeScript)

import { WalletManager } from '@juliaos/wallets';

// Initialize wallet manager
const walletManager = new WalletManager();

// Connect to browser wallet
await walletManager.connect('metamask');

// Get connected accounts
const accounts = await walletManager.getAccounts();
console.log('Connected account:', accounts[0]);

// Sign a message
const signature = await walletManager.signMessage('Hello, JuliaOS!');

// Prepare and sign a transaction
const transaction = {
  to: '0xRecipient...',
  value: '1000000000000000000', // 1 ETH in wei
  data: '0x',
};

const signedTx = await walletManager.signTransaction(transaction);

// Send a transaction
const txHash = await walletManager.sendTransaction(transaction);
console.log('Transaction sent:', txHash);

Backend Wallets (Julia)

using JuliaOS.Wallet

# Create a new wallet
wallet = Wallet.create_wallet("my_secure_password")
println("Created wallet with address: ", wallet["address"])

# Import from private key
imported_wallet = Wallet.import_wallet_from_private_key(
    "0x1234...",  # Private key
    "my_secure_password"
)

# Sign a transaction
signed_tx = Wallet.sign_transaction(
    wallet["id"],
    "ethereum",
    Dict(
        "to" => "0xRecipient...",
        "value" => "1000000000000000000",  # 1 ETH in wei
        "data" => "0x",
        "nonce" => 5,
        "gasLimit" => 21000,
        "maxFeePerGas" => "20000000000",
        "maxPriorityFeePerGas" => "1000000000"
    ),
    "my_secure_password"
)

# Get wallet balance
balance = Wallet.get_balance(wallet["id"], "ethereum", "ETH")
println("ETH Balance: ", balance)

Python Interface

import asyncio
from juliaos import JuliaOS

async def manage_wallets():
    juliaos_client = JuliaOS(host="localhost", port=8052)
    await juliaos_client.connect()

    # Backend wallet operations
    wallet = await juliaos_client.wallet.create_wallet("my_secure_password")
    print(f"Created wallet with address: {wallet['address']}")

    # Client-side wallet connection (in web context)
    # Note: This would typically be handled by frontend code
    connected_wallet = await juliaos_client.wallet.connect_external_wallet("metamask")
    print(f"Connected to external wallet: {connected_wallet['address']}")

    await juliaos_client.disconnect()

asyncio.run(manage_wallets())

CLI Usage

# Client-side wallet connection
juliaos wallet connect --type metamask

# Backend wallet management
juliaos wallet create --password "my_secure_password"
juliaos wallet import --type private-key
juliaos wallet list
juliaos wallet balance --id <wallet_id> --chain ethereum --token ETH

Integration with Agents and Swarms

Wallets in JuliaOS are tightly integrated with agents and swarms, allowing for automated blockchain interactions:

# Example of an agent using a wallet
function setup_trading_agent(wallet_id, password)
    # Create a trading agent with wallet access
    agent = Agents.create_agent(
        "TradingAgent",
        "trading",
        Dict(
            "wallet_id" => wallet_id,
            "chains" => ["ethereum", "polygon"],
            "tokens" => ["ETH", "USDC", "WBTC"]
        )
    )

    # Register wallet with agent (securely)
    Agents.register_wallet(agent["id"], wallet_id, password)

    return agent
end

# Execute a trade through the agent
function execute_trade(agent_id, from_token, to_token, amount)
    # Agent will use its registered wallet to sign and send the transaction
    result = Agents.execute_task(
        agent_id,
        Dict(
            "action" => "trade",
            "from_token" => from_token,
            "to_token" => to_token,
            "amount" => amount
        )
    )

    return result
end

Security Best Practices

  1. Use Hardware Wallets for high-value operations

  2. Strong Passwords for local wallet encryption

  3. Backup Seed Phrases securely offline

  4. Separate Wallets for different purposes

  5. Regular Audits of wallet activity

  6. Limited Permissions for agent-controlled wallets

  7. Test Transactions before sending large amounts

Future Enhancements

  • Multi-signature Wallet Support: For enhanced security in automated operations

  • MPC (Multi-Party Computation): For distributed key management

  • Additional Hardware Wallet Support: Expanding hardware wallet options

  • Enhanced Key Recovery: Additional recovery options for lost keys

  • Wallet Monitoring: Real-time monitoring and alerts for wallet activity

See also:

  • Wallets API (Frontend) - Client-side wallet integration

  • Managing Wallets (CLI) - CLI wallet management

  • Adding New Wallet Integrations - Extending wallet support

PreviousUse CasesNextPortfolio Optimization

Last updated 1 month ago