Cross-Chain Access SDK — API Reference
Full technical reference for all classes, methods, models, and exceptions in the Cross-Chain Access SDK.
CrossChainAccessClient
Location: swarm/cross_chain_access_sdk/sdk/client.py
Main entry point. Orchestrates authentication, market validation, on-chain USDC transfers, and order submission.
Constructor
CrossChainAccessClient(
network: Network,
private_key: str,
user_email: Optional[str] = None,
rpc_url: Optional[str] = None,
is_dev: bool = False,
)
| Parameter | Type | Required | Description |
|---|---|---|---|
| network | Network | ✅ | Blockchain network |
| private_key | str | ✅ | KYC-verified wallet private key |
| user_email | str | ❌ | Email for trade notifications |
| rpc_url | str | ❌ | Custom RPC endpoint |
| is_dev | bool | ❌ | Use development endpoints (default: False) |
Attributes: network, is_dev, cross_chain_access_api (CrossChainAccessAPIClient), web3_helper (Web3Helper), auth (SwarmAuth), usdc_address, topup_address
Raises: ValueError if USDC is not available on the specified network.
authenticate()
async def authenticate() -> None
Signs an EIP-191 authentication message with the wallet and obtains an access token. Called automatically when using async with.
Raises: AuthenticationError
check_trading_availability()
async def check_trading_availability() -> tuple[bool, str]
Validates all prerequisites for trading.
Returns: (is_available: bool, message: str)
Checks performed (in order):
- Market hours (14:30–21:00 UTC, Monday–Friday)
- Account not blocked
- Trading not suspended
- Transfers not restricted
- Market is open
Possible messages:
| Message | Meaning |
|---|---|
| "Trading is available" | All checks passed |
| "Market is closed. Opens in Xh Ym" | Outside market hours |
| "Trading not available: account blocked" | Account restriction |
| "Trading not available: trading blocked, transfers blocked" | Multiple restrictions |
get_quote()
async def get_quote(rwa_symbol: str) -> Quote
| Parameter | Type | Required | Description |
|---|---|---|---|
| rwa_symbol | str | ✅ | Trading symbol (e.g. "AAPL") |
Returns: Quote
rate: ask price (for buys) or bid price (for sells)source:"cross_chain_access"timestamp: current time
Raises: QuoteUnavailableException, InvalidSymbolException
buy()
async def buy(
rwa_token_address: str,
rwa_symbol: str,
user_email: str,
rwa_amount: Optional[Decimal] = None,
usdc_amount: Optional[Decimal] = None,
target_chain_id: Optional[int] = None,
) -> TradeResult
| Parameter | Type | Required | Description |
|---|---|---|---|
| rwa_token_address | str | ✅ | RWA token contract address |
| rwa_symbol | str | ✅ | Trading symbol (e.g. "AAPL") |
| user_email | str | ✅ | Email for trade confirmation |
| rwa_amount | Decimal | ⚠️ | Shares to buy (provide this or usdc_amount) |
| usdc_amount | Decimal | ⚠️ | USDC to spend (provide this or rwa_amount) |
| target_chain_id | int | ❌ | Network ID where assets will be delivered (any EVM chain) |
Trade flow:
- Validate market hours and account status
- Fetch real-time quote
- Calculate amounts with 1% slippage protection
- Validate buying power
- Transfer USDC to escrow on-chain
- Submit order to Cross-Chain Access API
- Send email confirmation
Returns: TradeResult
Raises: ValueError, MarketClosedException, AccountBlockedException, InsufficientFundsException, QuoteUnavailableException, OrderFailedException
sell()
async def sell(
rwa_token_address: str,
rwa_symbol: str,
user_email: str,
rwa_amount: Optional[Decimal] = None,
usdc_amount: Optional[Decimal] = None,
target_chain_id: Optional[int] = None,
) -> TradeResult
Parameters identical to buy(). Provide either rwa_amount (shares to sell) or usdc_amount (target USDC to receive).
Trade flow:
- Validate market hours and account status
- Fetch real-time quote
- Calculate amounts with 1% slippage protection
- Validate RWA token balance
- Transfer RWA tokens to escrow on-chain
- Submit order to Cross-Chain Access API
- Send email confirmation
Returns: TradeResult
close()
async def close() -> None
Closes HTTP clients. Called automatically with async with.
CrossChainAccessAPIClient
Location: swarm/cross_chain_access_sdk/cross_chain_access/client.py
HTTP client for the Cross-Chain Access API. Accessible via client.cross_chain_access_api.
get_account_status()
async def get_account_status() -> AccountStatus
Returns the account's current trading permissions and restrictions.
get_account_funds()
async def get_account_funds() -> AccountFunds
Returns buying power and cash balances.
get_asset_quote()
async def get_asset_quote(symbol: str) -> CrossChainAccessQuote
Fetches the raw bid/ask quote from the stock exchange for symbol.
create_order()
async def create_order(
symbol: str,
side: OrderSide,
quantity: Decimal,
notional: Optional[Decimal],
rwa_token_address: str,
user_email: str,
target_chain_id: Optional[int],
) -> CrossChainAccessOrderResponse
Submits a buy or sell order to the Cross-Chain Access API.
MarketHours
Location: swarm/cross_chain_access_sdk/market_hours/market_hours.py
Utility class for US stock market timing.
Market schedule
- Open: 14:30 UTC (9:30 AM EST)
- Close: 21:00 UTC (4:00 PM EST)
- Days: Monday–Friday
- Closed: weekends and US market holidays
is_market_open()
@staticmethod
def is_market_open() -> bool
Returns True if the market is currently open.
time_until_open()
@staticmethod
def time_until_open() -> timedelta
Returns the time remaining until the next market open.
time_until_close()
@staticmethod
def time_until_close() -> timedelta
Returns the time remaining until market close (only meaningful when market is open).
get_market_status()
@staticmethod
def get_market_status() -> tuple[bool, str]
Returns (is_open: bool, human_readable_message: str). Message examples:
"Market is open. Closes in 3h 15m""Market is closed. Opens in 8h 30m"
Data models
Quote
Shared with the Trading SDK. See Trading SDK API Reference — Data Models.
For Cross-Chain Access quotes: source = "cross_chain_access", rate = ask price for buys, bid price for sells.
TradeResult
Shared with the Trading SDK. See Trading SDK API Reference — Data Models.
For Cross-Chain Access results: source = "cross_chain_access".
OrderSide
class OrderSide(str, Enum):
BUY = "buy"
SELL = "sell"
AccountStatus
Location: swarm/cross_chain_access_sdk/cross_chain_access/models.py
| Field | Type | Description |
|---|---|---|
| account_blocked | bool | Account is blocked |
| trading_blocked | bool | Trading is blocked |
| transfers_blocked | bool | Transfers are blocked |
| trade_suspended_by_user | bool | User has suspended their own trading |
| market_open | bool | Market is currently open |
| account_status | str | Status string (e.g. "ACTIVE") |
Methods: is_trading_allowed() -> bool — returns True only if all restrictions are clear.
AccountFunds
Location: swarm/cross_chain_access_sdk/cross_chain_access/models.py
| Field | Type | Description |
|---|---|---|
| cash | Decimal | Available cash |
| buying_power | Decimal | Total buying power |
| day_trading_buying_power | Decimal | Day trading buying power |
| effective_buying_power | Decimal | Effective buying power |
| non_margin_buying_power | Decimal | Non-margin buying power |
| reg_t_buying_power | Decimal | Regulation T buying power |
Methods: has_sufficient_funds(required_amount: Decimal) -> bool
CrossChainAccessQuote
Raw quote from the stock exchange.
| Field | Type | Description |
|---|---|---|
| bid_price | Decimal | Best bid price |
| ask_price | Decimal | Best ask price |
| bid_size | Decimal | Size at bid |
| ask_size | Decimal | Size at ask |
| timestamp | datetime | Quote timestamp |
| bid_exchange | str | Exchange providing bid |
| ask_exchange | str | Exchange providing ask |
Methods: get_price_for_side(side: OrderSide) -> Decimal — returns ask for BUY, bid for SELL.
CrossChainAccessOrderResponse
| Field | Type | Description |
|---|---|---|
| order_id | str | Unique order identifier |
| symbol | str | Trading symbol |
| side | str | "buy" or "sell" |
| quantity | Decimal | Order quantity |
| filled_qty | Decimal | Filled quantity |
| status | str | Order status |
| created_at | datetime | Creation timestamp |
| filled_at | datetime | None | Fill timestamp |
Methods: to_dict() -> dict
Exceptions
Exception hierarchy
CrossChainAccessException (base)
├── MarketClosedException
├── AccountBlockedException
├── InsufficientFundsException
├── QuoteUnavailableException
├── OrderFailedException
└── InvalidSymbolException
| Exception | Location | When it occurs |
|---|---|---|
| CrossChainAccessException | cross_chain_access/exceptions.py | Base for all errors |
| MarketClosedException | Trade attempted outside market hours | |
| AccountBlockedException | Account blocked, trading/transfers suspended | |
| InsufficientFundsException | Insufficient USDC (buy) or RWA tokens (sell) | |
| QuoteUnavailableException | Real-time quote cannot be retrieved | |
| OrderFailedException | Order submission rejected by API | |
| InvalidSymbolException | Stock symbol not recognised |
Supported networks
| Network | Chain ID | Source network | Delivery via target_chain_id |
|---|---|---|---|
| Polygon | 137 | ✅ | ✅ |
| Ethereum | 1 | ✅ | ✅ |
| BSC | 56 | ✅ | ✅ |
| Base | 8453 | ✅ | ✅ |
| Any other EVM | — | ❌ | ✅ |
USDC addresses are automatically configured per source network. The target_chain_id for delivery can be any EVM-compatible network.
Rate limits & performance
- Quote latency: near real-time via API
- Order processing: near real-time (settlement depends on blockchain confirmation time)
- Retry logic: 3 attempts, exponential backoff — 1s, 2s, 4s
- Retried: network timeouts, 5xx errors, 429 rate limits
- Not retried: 4xx client errors (bad parameters, auth failures)
.png)