nautechsystems/nautilus_trader · error
Native currency not specified for chain {}
Error message
Native currency not specified for chain {} What it means
Blockchain::native_currency() panics when called on a blockchain variant that has no hard-coded native currency code/name mapping in the library. The match arm falls through to a catch-all panic for chains the crate has not been extended to support, so the error indicates the library lacks metadata for that chain rather than a caller mistake in values. It is a deliberate fail-fast instead of returning a bogus currency.
Source
Thrown at crates/model/src/defi/chain.rs:209
// Ethereum and Ethereum testnets
Blockchain::Ethereum | Blockchain::Sepolia | Blockchain::Holesky => ("ETH", "Ethereum"),
// Ethereum L2s that use ETH
Blockchain::Arbitrum
| Blockchain::ArbitrumNova
| Blockchain::ArbitrumSepolia
| Blockchain::Base
| Blockchain::BaseSepolia
| Blockchain::Optimism
| Blockchain::OptimismSepolia
| Blockchain::Blast
| Blockchain::BlastSepolia
| Blockchain::Scroll
| Blockchain::Linea => ("ETH", "Ethereum"),
Blockchain::Polygon | Blockchain::PolygonAmoy => ("POL", "Polygon"),
Blockchain::Avalanche | Blockchain::Fuji => ("AVAX", "Avalanche"),
Blockchain::Bsc | Blockchain::BscTestnet => ("BNB", "Binance Coin"),
_ => panic!("Native currency not specified for chain {}", self.name),
};
Currency::new(
code,
self.native_currency_decimals,
0,
name,
CurrencyType::Crypto,
)
}
/// Returns a reference to the `Chain` corresponding to the given `chain_id`, or `None` if it is not found.
#[must_use]
pub fn from_chain_id(chain_id: u32) -> Option<&'static Self> {
match chain_id {
2741 => Some(&chains::ABSTRACT),
42161 => Some(&chains::ARBITRUM),
42170 => Some(&chains::ARBITRUM_NOVA),View on GitHub (pinned to 18893faf8b)
Solutions
- Use a Blockchain variant that has a native currency mapping (ETH chains, Polygon, Avalanche, BSC, etc.)
- Check the match in crates/model/src/defi/chain.rs and add an arm for your chain, or upgrade nautilus_model to a version that supports the chain
- Wrap in catch_unwind or use a chain->currency mapping of your own before calling native_currency() for unsupported chains
Example fix
// before
let currency = chain.native_currency(); // panics for unsupported chain
// after
if let Ok(currency) = std::panic::catch_unwind(|| chain.native_currency()) {
// use currency
} else {
// supply fallback or reject the chain
} Defensive patterns
Strategy: validation
Validate before calling
// Only call native_currency() on supported chains
const SUPPORTED: &[Blockchain] = &[Blockchain::Ethereum, Blockchain::Arbitrum, Blockchain::Base, Blockchain::Optimism, Blockchain::Polygon, Blockchain::Avalanche, Blockchain::Bsc];
fn native_currency_safe(chain: Blockchain) -> Option<Currency> {
if SUPPORTED.contains(&chain) { Some(chain.native_currency()) } else { None }
} Type guard
fn has_native_currency(chain: Blockchain) -> bool {
!matches!(chain, Blockchain::Unknown) // extend with the unsupported set
} Try / catch
let currency = std::panic::catch_unwind(|| chain.native_currency())
.ok()
.and_then(|c| c.ok()) // adapt to your fallback Prevention
- Restrict chain configs to variants with known native currencies
- Check the match arms in crates/model/src/defi/chain.rs before adding a new chain to production config
- Add a startup assertion that every configured chain has native currency metadata
When it happens
Trigger: Calling native_currency() on a Blockchain variant not covered by the match arms (e.g. an exotic or newly added chain like Blockchain::Unknown or a chain added by a newer version without a native currency entry). Also occurs indirectly when constructing instruments or data for such a chain.
Common situations: Connecting to an unsupported testnet or L2; a version upgrade introduced a new Blockchain variant used in config before model metadata was updated; building a custom chain enum value and expecting dynamic lookup.
Related errors
- Must have the `chain` field set
- `InstrumentId` not applicable to `Block`
- Invalid factory address for DEX {name} on chain {chain} for
- Liquidity addition overflow: x={current}, y={y}, delta={delt
- Liquidity subtraction underflow: x={current}, y={y}, delta={
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/b85697b4b973ad96.
Report an issue: GitHub.