This example demonstrates how Apex SDK enables seamless interaction with Polkadot’s Asset Hub parachain alongside Ethereum, showcasing true cross-ecosystem asset management from a single Rust application.
Asset Hub (formerly Statemint) is Polkadot’s system parachain for creating and managing:
It provides:
// Need polkadot.js for Asset Hub
import { ApiPromise, WsProvider } from '@polkadot/api';
const assetHubApi = await ApiPromise.create({
provider: new WsProvider('wss://asset-hub...')
});
// Separate ethers.js for Ethereum
import { ethers } from 'ethers';
const ethProvider = new ethers.JsonRpcProvider('https://eth...');
// Two completely different APIs, runtime errors, complex integration
// Single SDK for everything
let sdk = ApexSDK::builder()
.with_substrate_endpoint("wss://asset-hub...")
.with_evm_endpoint("https://eth...")
.build()
.await?;
// Same API for both chains, compile-time safety
This example implements a complete asset lifecycle:
cd examples/parachain-assets
cargo run
// Create new asset on Asset Hub
let create_asset_tx = sdk.transaction()
.from_substrate_account(creator)
.to_substrate_account(asset_pallet)
.with_data(encode_create_asset(asset_id, creator, min_balance))
.build()?;
// Bridge from Asset Hub to Ethereum
let bridge_tx = sdk.transaction()
.from_substrate_account(creator)
.to_evm_address(eth_address) // Different ecosystem!
.amount(bridge_amount)
.build()?;
// SDK handles the complexity
assert!(bridge_tx.is_cross_chain());
Track the same asset across multiple chains:
All from a single application!
This pattern enables:
| Feature | Asset Hub | Ethereum ERC-20 |
|---|---|---|
| Creation Cost | ~$0.10 | $50-$500+ |
| Transfer Fee | ~$0.01 | $1-$50+ |
| Security | Polkadot validators | Contract security |
| Interoperability | Native XCM | Bridges required |
| Type Safety | Pallet-level | Contract-level |