Skip to main content

OneChainSelector

The OneChainSelector component renders a list of supported blockchain networks and lets the user select one for their AI trading order. It displays chain logos, names, and network types, and filters based on the strategy's supported chains.

React Native Only

OneChainSelector is exported from the React Native entry point of @one_deploy/sdk. It is not available on web.

Quick Start

import { useState } from 'react';
import { OneChainSelector } from '@one_deploy/sdk';

function ChainStep() {
const [chainId, setChainId] = useState<number | null>(null);

return (
<OneChainSelector
supportedChains={[8453, 1, 137, 42161]}
onSelect={(id) => {
setChainId(id);
console.log('Selected chain:', id);
}}
/>
);
}

OneChainSelectorProps

interface OneChainSelectorProps {
/** Array of chain IDs the strategy supports. Only these chains are shown. */
supportedChains: number[];

/** Currently selected chain ID. */
selectedChainId?: number;

/** Callback fired when the user selects a chain. */
onSelect: (chainId: number) => void;

/** Whether to show the network type label (Mainnet/Testnet). Defaults to true. */
showNetworkType?: boolean;

/** Whether to show chain logos. Defaults to true. */
showLogos?: boolean;

/** Override chain display data. Merged with CHAIN_CONFIG. */
chainConfig?: Partial<Record<number, ChainDisplayConfig>>;

/** Additional style applied to the container. */
style?: ViewStyle;

/** Style applied to each chain item. */
itemStyle?: ViewStyle;

/** Style applied to the selected chain item. */
selectedItemStyle?: ViewStyle;

/** Test ID for testing frameworks. */
testID?: string;
}

Props Table

PropTypeRequiredDefaultDescription
supportedChainsnumber[]Yes--Chain IDs to display
selectedChainIdnumberNo--Currently selected chain
onSelect(chainId: number) => voidYes--Selection callback
showNetworkTypebooleanNotrueShow Mainnet/Testnet label
showLogosbooleanNotrueShow chain logos
chainConfigPartial<Record<number, ChainDisplayConfig>>No--Custom chain display data
styleViewStyleNo--Container style
itemStyleViewStyleNo--Individual item style
selectedItemStyleViewStyleNo--Selected item style
testIDstringNo--Test ID

CHAIN_CONFIG Constant

The CHAIN_CONFIG constant provides display metadata for all supported chains.

import { CHAIN_CONFIG } from '@one_deploy/sdk';

// CHAIN_CONFIG is a Record<number, ChainDisplayConfig>
console.log(CHAIN_CONFIG[8453]);
// {
// chainId: 8453,
// name: 'Base',
// shortName: 'Base',
// logoUri: 'https://assets.one23.io/chains/base.png',
// nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
// networkType: 'mainnet',
// explorerUrl: 'https://basescan.org',
// rpcUrl: 'https://mainnet.base.org',
// }

ChainDisplayConfig Type

interface ChainDisplayConfig {
/** Chain ID. */
chainId: number;

/** Full chain name, e.g. "Ethereum Mainnet". */
name: string;

/** Short name for compact UIs, e.g. "ETH". */
shortName: string;

/** URI to the chain logo image. */
logoUri: string;

/** Native currency of the chain. */
nativeCurrency: {
name: string;
symbol: string;
decimals: number;
};

/** Whether this is a mainnet or testnet. */
networkType: 'mainnet' | 'testnet';

/** Block explorer base URL. */
explorerUrl: string;

/** Default RPC endpoint. */
rpcUrl: string;
}

Supported Chains

ChainChain IDName
Ethereum1Ethereum Mainnet
Polygon137Polygon PoS
Arbitrum42161Arbitrum One
Optimism10Optimism
Base8453Base
BSC56BNB Smart Chain
Avalanche43114Avalanche C-Chain
Ethereum Sepolia11155111Sepolia Testnet
Base Sepolia84532Base Sepolia Testnet
Polygon Amoy80002Polygon Amoy Testnet
Arbitrum Sepolia421614Arbitrum Sepolia Testnet

Usage Examples

With Strategy-Filtered Chains

import { OneChainSelector, useAIStrategies } from '@one_deploy/sdk';

function ChainSelection({ strategyId }: { strategyId: string }) {
const { strategies } = useAIStrategies();
const strategy = strategies.find((s) => s.id === strategyId);

if (!strategy) return null;

return (
<OneChainSelector
supportedChains={strategy.supportedChains}
onSelect={(chainId) => console.log('Chain:', chainId)}
/>
);
}

With Custom Styling

import { OneChainSelector } from '@one_deploy/sdk';

function StyledChainSelector() {
return (
<OneChainSelector
supportedChains={[8453, 1, 137]}
showNetworkType={true}
showLogos={true}
style={{
backgroundColor: '#0f0f1a',
borderRadius: 16,
padding: 12,
}}
itemStyle={{
paddingVertical: 14,
paddingHorizontal: 16,
borderRadius: 10,
marginBottom: 8,
backgroundColor: '#1a1a2e',
}}
selectedItemStyle={{
backgroundColor: '#2d2d5e',
borderWidth: 1,
borderColor: '#6366f1',
}}
onSelect={(chainId) => console.log('Selected:', chainId)}
/>
);
}

With Custom Chain Config

Override the display data for a specific chain or add a custom chain.

import { OneChainSelector } from '@one_deploy/sdk';

function CustomChainSelector() {
return (
<OneChainSelector
supportedChains={[8453, 1, 99999]}
chainConfig={{
8453: {
chainId: 8453,
name: 'Base (Recommended)',
shortName: 'Base',
logoUri: 'https://my-cdn.com/base-logo.png',
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
networkType: 'mainnet',
explorerUrl: 'https://basescan.org',
rpcUrl: 'https://mainnet.base.org',
},
99999: {
chainId: 99999,
name: 'My Custom Chain',
shortName: 'MCC',
logoUri: 'https://my-cdn.com/custom-chain.png',
nativeCurrency: { name: 'Custom Token', symbol: 'CTK', decimals: 18 },
networkType: 'mainnet',
explorerUrl: 'https://explorer.mychain.io',
rpcUrl: 'https://rpc.mychain.io',
},
}}
onSelect={(chainId) => console.log('Selected:', chainId)}
/>
);
}

Controlled Selection

import { useState } from 'react';
import { View, Text } from 'react-native';
import { OneChainSelector, CHAIN_CONFIG } from '@one_deploy/sdk';

function ControlledChainSelector() {
const [selectedChainId, setSelectedChainId] = useState<number | undefined>();

const chainName = selectedChainId
? CHAIN_CONFIG[selectedChainId]?.name ?? 'Unknown'
: 'None';

return (
<View>
<Text>Selected: {chainName}</Text>

<OneChainSelector
supportedChains={[8453, 1, 137, 42161, 10]}
selectedChainId={selectedChainId}
onSelect={setSelectedChainId}
/>
</View>
);
}

Next Steps