apex-sdk

Smart Contract Orchestration Example

This example demonstrates Apex SDK’s unique capability to orchestrate smart contract calls across both Substrate (ink!) and EVM chains from a single, unified Rust application.

What Makes This Unique

Unlike traditional approaches that require:

Apex SDK provides:

Use Case: Cross-Chain DeFi Application

The example implements a real-world DeFi workflow:

  1. Query balance from Substrate ink! contract (Westend)
  2. Execute token swap on EVM DEX (Ethereum Sepolia)
  3. Bridge assets from Ethereum to Polkadot
  4. Stake wrapped assets in Substrate staking contract
  5. Query final position across all chains

All operations use the same SDK with type-safe guarantees!

Running the Example

cd examples/contract-orchestration
cargo run

Key Features Demonstrated

1. Unified Transaction Building

// EVM transaction
let evm_tx = sdk.transaction()
    .from_evm_address(evm_account)
    .to_evm_address(contract)
    .with_data(call_data)
    .build()?;

// Substrate transaction
let substrate_tx = sdk.transaction()
    .from_substrate_account(substrate_account)
    .to_substrate_account(contract)
    .with_data(call_data)
    .build()?;

2. Cross-Chain Operations

// Automatically detects cross-chain transfers
let bridge_tx = sdk.transaction()
    .from_evm_address(evm_account)
    .to_substrate_account(substrate_account)  // Different chain!
    .amount(amount)
    .build()?;

assert!(bridge_tx.is_cross_chain());

3. Type-Safe Contract Calls

Both Substrate and EVM contract calls are:

Real-World Applications

This pattern enables:

Learn More