SDK Reference
SDK Reference
@rwatokens/sdk · TypeScript · v1.0.0 · Module-Aware Throughout
Complete TypeScript SDK for interacting with the platform's nine-layer infrastructure — ST22 Digital Securities token operations, Transfer Hook verification, custody oracle queries, NAV oracle queries (Module 2), Classification oracle queries (Module 3), CEDEX trading, portfolio management, and real-time data subscriptions. The SDK serves all three production modules — Equities (Module 1), Real Estate (Module 2), and CORECM — Carbon Ore, Rare Earth, and Critical Minerals (Module 3) — through a single client with module-aware helpers.
The SDK is published by Groovy Company, Inc. and is the primary integration surface for institutional integrators, trading-desk operators, custody systems, and analytics tooling. The same client instance handles mints from any of the three modules; module-specific behavior is surfaced through module-specific oracle helpers and module-aware fields on standard methods.
Table of Contents
Installation
Configuration
Client Initialization
Core Types
Transfer Hook Operations
Custody Oracle
NAV Oracle (Module 2)
Classification Oracle (Module 3)
Holding Period
CEDEX Trading
Portfolio Management
Market Data
WebSocket Subscriptions
Error Handling
Utilities
Security Best Practices
Network Configuration
Examples
1. Installation
Peer Dependencies
Requirements
Node.js
20 LTS+
TypeScript
5.0+
Solana CLI
1.18+ (for local development)
2. Configuration
Environment Variables
3. Client Initialization
Client Properties
The same RwaTokensClient instance handles mints from any of the three modules. There is no per-module client — module-aware helpers (client.oracle.getNAV() for Module 2; client.oracle.getClassification() for Module 3) work alongside cross-module methods (client.cedex.placeOrder(), client.custody.getAttestation()) on the same instance.
Program IDs
4. Core Types
Token Types
Account Types
5. Transfer Hook Operations
Verify Transfer Hook
Confirm an ST22 mint has the Transfer Hook permanently attached. The same method serves Module 1, Module 2, and Module 3 mints uniformly.
Get SecurityConfig
Read the full security configuration for an ST22 mint. Module-specific fields are populated per the mint's module.
Simulate Transfer
Dry-run a transfer against all 42 controls without submitting on chain. Returns which controls would pass or fail. Module-specific control extensions (Module 2 NAV-deviation, Module 3 federal-action) are evaluated automatically.
ControlResult type:
Check Wallet Eligibility
Verify if a wallet can receive ST22 tokens (passes investor verification controls IV-07 through IV-14). The eligibility check is module-agnostic at the wallet level — module-specific eligibility (e.g., Module 3 enhanced beneficial-ownership depth) is enforced at Empire onboarding, not at this method.
6. Custody Oracle
The Custody Oracle is module-agnostic. The same Empire Ed25519-signed attestation flow serves Module 1 (Common Class B equity), Module 2 (single-asset entity equity), and Module 3 (basin-asset entity equity). The asset class is recorded in the SecurityConfig metadata; the custody oracle tracks the unit count and the on-chain supply.
Get Custody Attestation
Verify Ed25519 Signature
Independently verify the Empire attestation signature.
Watch Custody (Real-Time)
Subscribe to custody attestation updates (~400ms per block). Works uniformly across modules.
7. NAV Oracle (Module 2)
The NAV Oracle holds the most recent appraised Net Asset Value for a Module 2 ST22 mint. Calls are valid only for Module 2 mints — calling these methods against a Module 1 or Module 3 mint returns null.
Get NAV Oracle
Compute NAV Deviation
Convenience helper to compute the on-chain price's deviation from the most recent NAV.
Watch NAV (Real-Time)
8. Classification Oracle (Module 3)
The Classification Oracle holds the most recent USGS Critical Minerals List classification, DOE Critical Materials Strategy status, and federal-action status for a Module 3 ST22 mint's basin asset. Calls are valid only for Module 3 mints — calling these methods against a Module 1 or Module 2 mint returns null.
Get Classification Oracle
Watch Classification (Real-Time)
The classification subscription emits both routine refresh events and high-severity federal-action events. Federal-action events warrant immediate operational response under the Incident Response Playbook §13.
9. Holding Period
Get Holding Period Status
Check an investor's holding period status for a specific ST22 mint. The same method serves Reg D, Reg S, and Reg CF investors regardless of which module the mint belongs to.
Batch Holding Period Query
Check holding status across multiple mints for a single wallet. The query handles mints from any combination of modules in a single call.
PDA Derivation
10. CEDEX Trading
All CEDEX trading operations require an authenticated wallet that has passed Empire Stock Transfer KYC, KYB, AML, OFAC, and KYW verification. The same method signatures serve mints from all three modules; module-specific behavior surfaces inside the pre-flight compliance pipeline.
Place Order
Compliance flow. Every order passes through pre-flight compliance verification (2–3 seconds) before on-chain execution. The pre-flight pipeline includes module-aware checks: Module 2 orders are pre-validated against the NAV-deviation tolerance; Module 3 orders are pre-validated against Classification freshness and federal-action status. If any check would reject the trade, the SDK returns the specific error code before submitting on chain — saving the user transaction fees.
Cancel Order
Get Open Orders
Estimate Swap Output
Preview a swap without executing — returns expected output, price impact, fee breakdown, and module-aware pre-flight result.
11. Portfolio Management
Get Portfolio
Returns all ST22 holdings for a wallet across all modules with holding-period status, custody-verification status, and module-aware oracle status.
Get Position Detail
12. Market Data
List Markets
Get Order Book
Get Recent Trades
Get OHLCV (Candlestick Data)
13. WebSocket Subscriptions
Real-time data via WebSocket connection to CEDEX. Module-specific channels (nav for Module 2; classification for Module 3) work alongside cross-module channels on the same WebSocket connection.
Subscribe to Order Book
Subscribe to Trades
Subscribe to Custody Oracle
Real-time custody attestation updates (~400ms per block). Cross-module — works for Module 1, Module 2, and Module 3 mints.
Subscribe to NAV Oracle (Module 2)
Subscribe to Classification Oracle (Module 3)
Subscribe to Circuit Breaker Events
Disconnect
14. Error Handling
RwaTokensError Class
All SDK errors extend RwaTokensError with structured error data. Module-specific control failures expose a moduleScope field on details indicating which module's variant fired.
Error Code Registry
6001
CustodyDiscrepancy
Custody
No — system-level
All
Wait for oracle consensus. Contact platform support.
6002
CustodyOracleUnavailable
Custody
Yes — transient
All
Retry after 1 block (~400ms).
6003
SenderSanctioned
Sanctions
No
All
OFAC-flagged wallet. Cannot trade.
6004
ReceiverSanctioned
Sanctions
No
All
Receiver is OFAC-flagged. Cannot receive.
6005
OfacOracleStale
Sanctions
Yes — transient
All
OFAC oracle refreshing. Retry in minutes.
6006
AMLHighRisk
AML
No
All
AML score >70. Contact Empire Stock Transfer.
6007
InvalidSigner
CEI
No
All
Transaction not properly signed.
6008–6019
Structural Integrity
CEI
Varies
All
See detailed error message.
6020
WalletLimitExceeded
Position
Yes
All
Reduce order size below per-mint cap (4.99% default; up to 9.99% for some Module 2 mints).
6021
PriceImpactExceeded
Circuit Breaker
Yes
All; M2 includes NAV-deviation variant
Reduce order size or split. M2: check NAV deviation.
6022
VelocityExceeded
Position
Yes — timed
All
Slow down — wait for velocity window.
6023
CrossWalletDetected
Position
No
All
Behavioral clustering flagged. Contact compliance.
6024
TokensLocked
Holding Period
Yes — timed
All; Reg D / Reg S / Reg CF variants
Wait for the applicable Reg D / Reg S / Reg CF holding period.
6036
GlobalCircuitBreaker
Emergency
Yes — timed
All
All trading halted. Wait for cooldown (15 min).
6037
DailySellLimitExceeded
Volume
Yes — timed
All
30% daily sell limit reached. Wait 24h.
6038
CustodyDiscrepancyHalt
Emergency
No — system-level
All
Custody issue. Wait for 2-of-3 oracle consensus.
6039
OFACEmergencyBlock
Emergency
No
All
Treasury emergency SDN update.
6040
OracleConsensusFail
Emergency
Yes — transient
All
Oracle consensus not reached. Retry.
6041
ControlledMigration
Governance
Yes — timed
All
Upgrade in progress. Wait for completion.
6042
RegulatoryOverride
Regulatory
No
All; M3 includes federal-action variant
Legal Counsel + 3-of-5 multi-sig freeze. M3: federal action active.
Error Recovery Pattern
15. Utilities
PDA Derivation
Format Helpers
Anchor IDL
Access the raw Anchor IDL for advanced use cases.
16. Security Best Practices
Wallet Key Management
Transaction Verification
Rate Limiting
17. Network Configuration
Devnet
Mainnet
Localnet (Development)
18. Examples
Example 1: Verify an ST22 Token (any module)
Example 2: Check Holding Period Before Selling
Example 3: Real-Time Custody Monitoring (cross-module)
Example 4: Module 2 NAV Monitoring
Example 5: Module 3 Federal-Action Monitoring
Example 6: Simulate Before Trading (module-aware)
Changelog
v1.0.0 (Q3 2026)
Initial release — mainnet support across all three modules at launch.
Module-aware client supporting Module 1 (Equities), Module 2 (Real Estate), and Module 3 (CORECM) on a single
RwaTokensClientinstance.Transfer Hook verification and module-aware simulation.
Custody oracle queries with Ed25519 verification (cross-module).
NAV oracle queries (Module 2) and Classification oracle queries (Module 3).
Holding period status with Reg D, Reg S, and Reg CF regime support; batch queries.
CEDEX order placement, cancellation, and module-aware pre-flight estimation.
Portfolio management with module-aware position surfacing (NAV status, classification status).
Market data (order book, trades, OHLCV) with module filter.
WebSocket subscriptions including module-specific NAV (M2) and Classification (M3) channels.
Full error code registry with module-aware variants for 6021 (NAV-deviation) and 6042 (federal-action).
PDA derivation utilities including NAV oracle and Classification oracle.
Anchor IDL exports.
Ledger hardware wallet support.
License
Business Source License 1.1 — See LICENSE.
Related Documentation
CEDEX API Reference — REST and WebSocket endpoints with module-aware surface.
CEDEX API Changelog — Version history with module-aware migration guides.
Smart Contract Reference — On-chain program documentation including module-aware program behavior.
Transfer Hook Reference — Standalone reference for the 42 controls and module-aware extensions.
Oracle Integration Guide — Custody, OFAC, AML, TWAP, EDGAR (M1), NAV (M2), and Classification (M3) relay architecture.
Network Configuration — Mainnet program IDs, RPC endpoints, oracle PDAs.
Incident Response Playbook — P0 through P3 runbooks; Module 3 federal-action freeze runbook (§13).
@rwatokens/sdk · RWA Tokens · Groovy Company, Inc.
Last updated
Was this helpful?