orderly-sdk-install-dependency
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOrderly Network: SDK Install Dependency
Orderly Network:SDK依赖安装
Use this skill to add Orderly SDK packages to your project. The SDK is modular—install only what you need.
使用本指南将Orderly SDK包添加到你的项目中。该SDK采用模块化设计——仅安装你需要的部分即可。
When to Use
适用场景
- Starting a new DEX project
- Adding Orderly SDK to an existing project
- Installing specific packages for custom integrations
- Setting up wallet connectors
- 启动新的DEX项目
- 为现有项目集成Orderly SDK
- 安装特定包以实现自定义集成
- 配置钱包连接器
Prerequisites
前置要求
- Node.js 18+ installed
- npm, yarn, or pnpm package manager
- React 18+ project (for UI packages)
- 已安装Node.js 18+
- 已安装npm、yarn或pnpm包管理器
- React 18+项目(针对UI包)
Quick Start (Full DEX)
快速上手(完整DEX)
IMPORTANT: A functional DEX requires BOTH the Orderly packages AND the wallet connector dependencies. Thepackage needs@orderly.network/wallet-connectorpackages for EVM wallets and@web3-onboard/*packages for Solana wallets.@solana/wallet-adapter-*Note:is included as a transitive dependency via@orderly.network/hooks— you do not need to install it separately for most DEX projects. Only install it directly if you are using the hooks-only integration path without@orderly.network/react-app.react-app
bash
undefined重要提示:一个可用的DEX同时需要Orderly包和钱包连接器依赖。包需要@orderly.network/wallet-connector包以支持EVM钱包,需要@web3-onboard/*包以支持Solana钱包。@solana/wallet-adapter-*注意:是@orderly.network/hooks的传递依赖——对于大多数DEX项目,你无需单独安装它。仅当你使用不依赖@orderly.network/react-app的纯hooks集成方案时,才需要直接安装它。react-app
bash
undefinedOrderly SDK packages
Orderly SDK包
npm install @orderly.network/react-app
@orderly.network/trading
@orderly.network/portfolio
@orderly.network/markets
@orderly.network/wallet-connector
@orderly.network/i18n
@orderly.network/trading
@orderly.network/portfolio
@orderly.network/markets
@orderly.network/wallet-connector
@orderly.network/i18n
npm install @orderly.network/react-app
@orderly.network/trading
@orderly.network/portfolio
@orderly.network/markets
@orderly.network/wallet-connector
@orderly.network/i18n
@orderly.network/trading
@orderly.network/portfolio
@orderly.network/markets
@orderly.network/wallet-connector
@orderly.network/i18n
REQUIRED: EVM wallet support (MetaMask, WalletConnect, etc.)
必需:EVM钱包支持(MetaMask、WalletConnect等)
npm install @web3-onboard/injected-wallets @web3-onboard/walletconnect
npm install @web3-onboard/injected-wallets @web3-onboard/walletconnect
REQUIRED: Solana wallet support (Phantom, Solflare, etc.)
必需:Solana钱包支持(Phantom、Solflare等)
npm install @solana/wallet-adapter-base @solana/wallet-adapter-wallets
undefinednpm install @solana/wallet-adapter-base @solana/wallet-adapter-wallets
undefinedPackage Reference
包参考
Core Packages
核心包
| Package | Description | Key Exports |
|---|---|---|
| Main app provider, config context, error boundary | |
| React hooks for trading, account, orders, positions | |
| TypeScript type definitions and constants | |
| Base UI components (buttons, inputs, dialogs, tables) | |
| Internationalization (i18n) support | |
| Utility functions (formatting, math, dates) | |
bash
npm install @orderly.network/react-app @orderly.network/hooks @orderly.network/types @orderly.network/ui @orderly.network/i18n| 包名 | 描述 | 主要导出项 |
|---|---|---|
| 主应用提供者、配置上下文、错误边界 | |
| 用于交易、账户、订单、仓位的React hooks | |
| TypeScript类型定义和常量 | |
| 基础UI组件(按钮、输入框、对话框、表格) | |
| 国际化(i18n)支持 | |
| 工具函数(格式化、数学计算、日期处理) | |
bash
npm install @orderly.network/react-app @orderly.network/hooks @orderly.network/types @orderly.network/ui @orderly.network/i18nFeature Widgets (High-Level Pages)
功能组件(高阶页面)
Complete, pre-built page components with full functionality.
| Package | Description | Key Exports |
|---|---|---|
| Full trading page (chart, orderbook, order entry, positions) | |
| Portfolio dashboard (positions, orders, assets, history) | |
| Markets listing page with prices and stats | |
| Vault/Earn products page | |
| Referral/affiliate program page | |
| Trading competition leaderboard | |
| Trading rewards program page | |
| Trading points/merits program page | |
bash
npm install @orderly.network/trading @orderly.network/portfolio @orderly.network/markets功能完整的预构建页面组件。
| 包名 | 描述 | 主要导出项 |
|---|---|---|
| 完整交易页面(图表、订单簿、下单界面、仓位管理) | |
| 投资组合仪表盘(仓位、订单、资产、历史记录) | |
| 市场列表页面(含价格和统计数据) | |
| 金库/理财产品页面 | |
| 推荐/联盟计划页面 | |
| 交易竞赛排行榜 | |
| 交易奖励计划页面 | |
| 交易积分/荣誉计划页面 | |
bash
npm install @orderly.network/trading @orderly.network/portfolio @orderly.network/marketsWallet Connectors
钱包连接器
Choose one wallet connection strategy.
| Package | Description | Key Exports |
|---|---|---|
| Standard connector (Web3-Onboard + Solana adapters) | |
| Privy connector (social login, embedded wallets) | |
Option A: Standard Wallet Connector (Recommended)
Supports EVM (MetaMask, WalletConnect, Binance, etc.) and Solana (Phantom, Solflare).
Note: Theworks with sensible defaults. Installing the underlying wallet packages (@orderly.network/wallet-connector,@web3-onboard/*) is optional and only needed for custom wallet configuration (e.g., adding WalletConnect with a project ID). The official templates use@solana/wallet-adapter-*with no props and no extra wallet packages.<WalletConnectorProvider>
bash
undefined选择一种钱包连接方案。
| 包名 | 描述 | 主要导出项 |
|---|---|---|
| 标准连接器(Web3-Onboard + Solana适配器) | |
| Privy连接器(社交登录、嵌入式钱包) | |
方案A:标准钱包连接器(推荐)
支持EVM(MetaMask、WalletConnect、Binance等)和Solana(Phantom、Solflare)钱包。
注意:具备合理的默认配置。安装底层钱包包(@orderly.network/wallet-connector、@web3-onboard/*)是可选操作,仅在需要自定义钱包配置时才需安装(例如,添加带项目ID的WalletConnect)。官方模板使用不带任何属性的@solana/wallet-adapter-*,无需额外安装钱包包。<WalletConnectorProvider>
bash
undefinedMain connector package
主连接器包
npm install @orderly.network/wallet-connector
npm install @orderly.network/wallet-connector
Optional: EVM wallet packages (for custom WalletConnect, etc.)
可选:EVM钱包包(用于自定义WalletConnect等)
npm install @web3-onboard/injected-wallets @web3-onboard/walletconnect
npm install @web3-onboard/injected-wallets @web3-onboard/walletconnect
Optional: Solana wallet packages (for custom Solana wallet config)
可选:Solana钱包包(用于自定义Solana钱包配置)
npm install @solana/wallet-adapter-base @solana/wallet-adapter-wallets
**Option B: Privy Connector**
For social login (Google, email, etc.) and embedded wallets.
```bash
npm install @orderly.network/wallet-connector-privy @privy-io/react-authnpm install @solana/wallet-adapter-base @solana/wallet-adapter-wallets
**方案B:Privy连接器**
适用于社交登录(谷歌、邮箱等)和嵌入式钱包。
```bash
npm install @orderly.network/wallet-connector-privy @privy-io/react-authUI Sub-Packages (Granular Components)
UI子包(细粒度组件)
Individual UI modules for custom integrations. These are dependencies of and , but can be installed separately.
@orderly.network/trading@orderly.network/portfolio| Package | Description | Key Exports |
|---|---|---|
| App layout scaffold, navigation, account menu | |
| Order entry form component | |
| Positions table component | |
| Orders table component | |
| Deposit/withdraw/transfer dialogs | |
| Leverage selector component | |
| Take profit / stop loss form | |
| PnL sharing card generator | |
| Chain/network selector dropdown | |
| Wallet connect button & modal | |
| TradingView chart wrapper | |
| Notification center | |
bash
npm install @orderly.network/ui-scaffold @orderly.network/ui-order-entry用于自定义集成的独立UI模块。这些包是和的依赖,但也可以单独安装。
@orderly.network/trading@orderly.network/portfolio| 包名 | 描述 | 主要导出项 |
|---|---|---|
| 应用布局框架、导航栏、账户菜单 | |
| 下单表单组件 | |
| 仓位表格组件 | |
| 订单表格组件 | |
| 存入/提取/转账对话框 | |
| 杠杆选择器组件 | |
| 止盈/止损表单 | |
| PnL分享卡片生成器 | |
| 链/网络选择下拉框 | |
| 钱包连接按钮及弹窗 | |
| TradingView图表包装器 | |
| 通知中心 | |
bash
npm install @orderly.network/ui-scaffold @orderly.network/ui-order-entryLow-Level Packages
底层包
For advanced customization or non-React environments.
| Package | Description | Key Exports |
|---|---|---|
| Low-level API client, signing, key management | |
| Perpetual trading calculations (margin, liquidation) | |
| Network/WebSocket layer | |
| Default EVM wallet adapter | |
| Default Solana wallet adapter | |
bash
npm install @orderly.network/core @orderly.network/perp用于高级自定义或非React环境。
| 包名 | 描述 | 主要导出项 |
|---|---|---|
| 底层API客户端、签名、密钥管理 | |
| 永续合约交易计算(保证金、清算) | |
| 网络/WebSocket层 | |
| 默认EVM钱包适配器 | |
| 默认Solana钱包适配器 | |
bash
npm install @orderly.network/core @orderly.network/perpInstallation by Use Case
按使用场景安装
Minimal Setup (Hooks Only)
最小配置(仅Hooks)
For building fully custom UI with hooks.
bash
npm install @orderly.network/react-app \
@orderly.network/hooks \
@orderly.network/types \
@orderly.network/wallet-connector用于构建完全自定义的UI界面。
bash
npm install @orderly.network/react-app \
@orderly.network/hooks \
@orderly.network/types \
@orderly.network/wallet-connectorFull DEX with All Features
包含全部功能的完整DEX
bash
npm install @orderly.network/react-app \
@orderly.network/trading \
@orderly.network/portfolio \
@orderly.network/markets \
@orderly.network/vaults \
@orderly.network/affiliate \
@orderly.network/trading-leaderboard \
@orderly.network/wallet-connector \
@orderly.network/i18n \
@orderly.network/uibash
npm install @orderly.network/react-app \
@orderly.network/trading \
@orderly.network/portfolio \
@orderly.network/markets \
@orderly.network/vaults \
@orderly.network/affiliate \
@orderly.network/trading-leaderboard \
@orderly.network/wallet-connector \
@orderly.network/i18n \
@orderly.network/uiCustom UI with Scaffold Layout
带框架布局的自定义UI
bash
npm install @orderly.network/react-app \
@orderly.network/hooks \
@orderly.network/ui \
@orderly.network/ui-scaffold \
@orderly.network/ui-order-entry \
@orderly.network/ui-positions \
@orderly.network/wallet-connectorbash
npm install @orderly.network/react-app \
@orderly.network/hooks \
@orderly.network/ui \
@orderly.network/ui-scaffold \
@orderly.network/ui-order-entry \
@orderly.network/ui-positions \
@orderly.network/wallet-connectorPrivy (Social Login) Setup
Privy(社交登录)配置
bash
npm install @orderly.network/react-app \
@orderly.network/trading \
@orderly.network/wallet-connector-privy \
@privy-io/react-authbash
npm install @orderly.network/react-app \
@orderly.network/trading \
@orderly.network/wallet-connector-privy \
@privy-io/react-authPeer Dependencies
对等依赖
All packages require:
json
{
"peerDependencies": {
"react": ">=18",
"react-dom": ">=18"
}
}所有包均要求:
json
{
"peerDependencies": {
"react": ">=18",
"react-dom": ">=18"
}
}Tailwind CSS Setup
Tailwind CSS配置
The UI packages require Tailwind CSS with the Orderly preset:
bash
npm install -D tailwindcss postcss autoprefixertailwind.config.ts:
ts
import { OUITailwind } from '@orderly.network/ui';
export default {
content: ['./src/**/*.{js,ts,jsx,tsx}', './node_modules/@orderly.network/**/*.{js,mjs}'],
presets: [OUITailwind.preset],
};CSS entry file:
Important: Onlyhas a CSS file. Other packages (@orderly.network/ui,trading,portfolio) do NOT have separate CSS files—they use the base UI styles.markets
css
/* Only import from @orderly.network/ui - other packages don't have CSS files */
@import '@orderly.network/ui/dist/styles.css';
@tailwind base;
@tailwind components;
@tailwind utilities;UI包需要搭配Tailwind CSS及Orderly预设使用:
bash
npm install -D tailwindcss postcss autoprefixertailwind.config.ts:
ts
import { OUITailwind } from '@orderly.network/ui';
export default {
content: ['./src/**/*.{js,ts,jsx,tsx}', './node_modules/@orderly.network/**/*.{js,mjs}'],
presets: [OUITailwind.preset],
};CSS入口文件:
重要提示:仅包含CSS文件。其他包(@orderly.network/ui、trading、portfolio)没有独立的CSS文件——它们依赖基础UI样式。markets
css
/* 仅从@orderly.network/ui导入样式——其他包无CSS文件 */
@import '@orderly.network/ui/dist/styles.css';
@tailwind base;
@tailwind components;
@tailwind utilities;Vite Polyfills (Required)
Vite Polyfills(必需)
The wallet connector packages use Node.js built-ins like . You must add polyfills for browser compatibility:
Bufferbash
npm install -D vite-plugin-node-polyfillsvite.config.ts:
ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
export default defineConfig({
plugins: [
react(),
nodePolyfills({
include: ['buffer', 'crypto', 'stream', 'util'],
globals: {
Buffer: true,
global: true,
process: true,
},
}),
],
});钱包连接器包使用了等Node.js内置模块。你必须添加polyfills以保证浏览器兼容性:
Bufferbash
npm install -D vite-plugin-node-polyfillsvite.config.ts:
ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
export default defineConfig({
plugins: [
react(),
nodePolyfills({
include: ['buffer', 'crypto', 'stream', 'util'],
globals: {
Buffer: true,
global: true,
process: true,
},
}),
],
});Version Compatibility
版本兼容性
All packages should use the same version to ensure compatibility.
@orderly.network/*json
{
"dependencies": {
"@orderly.network/react-app": "^2.8.0",
"@orderly.network/trading": "^2.8.0",
"@orderly.network/hooks": "^2.8.0",
"@orderly.network/ui": "^2.8.0"
}
}所有包应使用相同版本以确保兼容性。
@orderly.network/*json
{
"dependencies": {
"@orderly.network/react-app": "^2.8.0",
"@orderly.network/trading": "^2.8.0",
"@orderly.network/hooks": "^2.8.0",
"@orderly.network/ui": "^2.8.0"
}
}Package Manager Commands
包管理器命令
npm:
bash
npm install <package-name>yarn:
bash
yarn add <package-name>pnpm:
bash
pnpm add <package-name>npm:
bash
npm install <package-name>yarn:
bash
yarn add <package-name>pnpm:
bash
pnpm add <package-name>Related Skills
相关指南
- orderly-sdk-dex-architecture - Project structure and provider setup
- orderly-sdk-wallet-connection - Wallet integration details
- orderly-sdk-page-components - Using pre-built page components
- orderly-sdk-trading-workflows - End-to-end trading implementation
- orderly-sdk-theming - Customizing the UI appearance
- orderly-sdk-dex-architecture - 项目结构与提供者配置
- orderly-sdk-wallet-connection - 钱包集成详情
- orderly-sdk-page-components - 预构建页面组件使用
- orderly-sdk-trading-workflows - 端到端交易流程实现
- orderly-sdk-theming - UI外观自定义