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.
Unlike traditional approaches that require:
polkadot.js for Substrate interactionsethers.js or web3.js for EVM interactionsApex SDK provides:
The example implements a real-world DeFi workflow:
All operations use the same SDK with type-safe guarantees!
cd examples/contract-orchestration
cargo run
// 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()?;
// 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());
Both Substrate and EVM contract calls are:
This pattern enables: