Page cover

Bridges (Cross-Chain)

JuliaOS provides comprehensive modules for facilitating communication and asset transfers between different blockchain networks. This is crucial for agents or strategies that operate across multiple ecosystems (e.g., arbitrage between Ethereum and Solana, portfolio management across chains).

Concept

A cross-chain bridge allows users or applications to lock an asset on one chain and receive a representation of that asset (a wrapped token) or a different asset on another chain. This typically involves:

  • Source Chain Contract: Where the original asset is locked or burned

  • Target Chain Contract: Where the wrapped asset is minted or the corresponding asset is released

  • Messaging/Verification Layer: A mechanism to securely communicate the lock/burn event from the source chain to the target chain

Bridge Types

JuliaOS supports several types of bridge architectures:

1. Guardian/Validator Networks

  • Description: A network of validators observes events on the source chain and produces signed attestations that are verified on the target chain

  • Examples: Wormhole, Axelar, LayerZero

  • Security Model: Security depends on the honesty of a supermajority of validators

  • Advantages: High security, broad chain support, decentralized verification

2. Liquidity Networks

  • Description: Uses liquidity pools on both chains to facilitate transfers without actually moving assets across chains

  • Examples: Connext, Hop Protocol

  • Security Model: Security depends on the liquidity providers and the economic incentives

  • Advantages: Fast finality, no reliance on external validators

3. Light Clients

  • Description: Uses cryptographic proofs from the source chain that are verified by a light client on the target chain

  • Examples: IBC (Inter-Blockchain Communication Protocol)

  • Security Model: Security inherits from the underlying blockchain consensus

  • Advantages: Highest security, no trusted third parties

4. Centralized/Federated Bridges

  • Description: Relies on a centralized or federated set of operators to relay messages

  • Examples: Relay Bridge (custom JuliaOS implementation)

  • Security Model: Security depends on the trustworthiness of the operators

  • Advantages: Simplicity, speed, flexibility

Supported Bridges in JuliaOS

JuliaOS integrates with multiple bridge protocols, providing a unified interface for cross-chain operations:

Wormhole Bridge

  • Type: Guardian Network

  • Implementation: Full integration with the Wormhole protocol

  • Supported Chains:

    • EVM: Ethereum, Polygon, Arbitrum, Optimism, Avalanche, BSC, Base, Fantom

    • Non-EVM: Solana, Aptos, Sui

  • Supported Assets: Native tokens, ERC-20/SPL tokens, NFTs

  • Features:

    • Token transfers across all supported chains

    • NFT bridging between supported chains

    • Cross-chain messaging for complex operations

    • Automatic VAA (Verified Action Approval) handling

    • Status tracking and error recovery

  • Security: High security through decentralized guardian network

  • Use Case: Production applications requiring robust security and broad interoperability

Relay Bridge

  • Type: Centralized/Federated

  • Implementation: Custom-built bridge with a relayer service

  • Supported Chains:

    • EVM: Ethereum (mainnet and testnets), Base, Polygon

    • Non-EVM: Solana

  • Supported Assets: Native tokens, ERC-20/SPL tokens

  • Features:

    • Fast token transfers between supported chains

    • Simplified user experience (single transaction)

    • Automatic transaction monitoring and relay

    • Lower fees for specific chain pairs

  • Security: Moderate security, relies on the relayer's integrity

  • Use Case: Testing, development, specific trusted environments

Axelar Bridge

  • Type: Guardian Network

  • Implementation: Integration with the Axelar network

  • Supported Chains:

    • EVM: Ethereum, Polygon, Avalanche, Fantom, Moonbeam

    • Non-EVM: Cosmos ecosystem chains

  • Supported Assets: Native tokens, ERC-20 tokens, IBC tokens

  • Features:

    • General Message Passing (GMP) for complex cross-chain operations

    • Token transfers across all supported chains

    • Cross-chain contract calls

  • Security: High security through validator network

  • Use Case: Applications requiring interoperability with Cosmos ecosystem

LayerZero Bridge

  • Type: Oracle and Relayer Network

  • Implementation: Integration with the LayerZero protocol

  • Supported Chains: Ethereum, Polygon, Arbitrum, Optimism, Avalanche, BSC, Fantom

  • Supported Assets: Native tokens, ERC-20 tokens

  • Features:

    • Ultra-light nodes for verification

    • Configurable security model

    • Cross-chain messaging

  • Security: Configurable security based on application needs

  • Use Case: Applications requiring customizable security parameters

Implementation Details

Architecture

The bridge implementation in JuliaOS follows a modular architecture:

  1. Bridge.jl: Core Julia module that provides a unified interface for all bridges

  2. Bridge Packages: TypeScript/JavaScript packages in /packages/bridges/ that implement specific bridge protocols

  3. Bridge Adapters: Adapters that connect the Julia backend to the TypeScript/JavaScript implementations

Workflow

The typical workflow for a cross-chain transfer in JuliaOS:

  1. Initiation: A user or agent requests a cross-chain transfer, specifying:

    • Source chain and token

    • Target chain and token

    • Amount to transfer

    • Recipient address

    • Bridge to use (optional, can be automatically selected)

  2. Backend Processing:

    • The request is routed to the Bridge.jl module

    • Bridge.jl validates the request and prepares the necessary parameters

    • The appropriate bridge adapter is selected based on the request

  3. Bridge-Specific Execution:

    • Wormhole:

      • Prepares and sends a transaction to the Wormhole contract on the source chain

      • Waits for the VAA to be produced by the guardian network

      • Fetches the VAA and prepares a transaction for the target chain

      • Submits the VAA to the target chain to complete the transfer

    • Relay Bridge:

      • Prepares and sends a transaction to the bridge contract on the source chain

      • The relayer monitors for events and automatically submits the corresponding transaction on the target chain

    • Other Bridges: Follow their specific protocols

  4. Status Tracking and Completion:

    • The bridge provides status updates throughout the process

    • The transfer is marked complete when the assets are available on the target chain

    • Error handling and recovery mechanisms are provided for failed transfers

Using Bridges

From Julia

From TypeScript/JavaScript

From Python

From CLI

Advanced Features

Bridge Selection

JuliaOS can automatically select the optimal bridge based on various factors:

Cross-Chain Messaging

Some bridges support general message passing for complex cross-chain operations:

Batch Transfers

JuliaOS supports batching multiple transfers for efficiency:

See also:

  • Cross-Chain (CLI) - User guide for CLI interaction

  • Bridge API (Backend) - Technical details of the Bridge.jl module

  • Adding New Bridges - Guide for extending JuliaOS with new bridge protocols