一键导入
nexus-one-swaps
Scaffolding, configuration, and integration of the Nexus One component in swap mode (config.mode = "swap"). Handles cross-chain swaps and bridges.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scaffolding, configuration, and integration of the Nexus One component in swap mode (config.mode = "swap"). Handles cross-chain swaps and bridges.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
End-to-end integration guide for Nexus Elements. Use Nexus One as the single unified component for all swap, send, and deposit flows. Legacy standalone widgets (FastBridge, FastTransfer, SwapWidget, Deposit, BridgeDeposit, UnifiedBalance, ViewHistory) have been deprecated and removed.
Scaffolding, configuration, and integration of the Nexus One component in deposit mode (config.mode = "deposit"). Handles swapping assets and executing custom smart contract calls on the destination chain.
Scaffolding, configuration, and integration of the Nexus One component in send mode (config.mode = "send"). Used to send tokens to an external recipient address cross-chain.
DEPRECATED — BridgeDeposit has been removed. Use Nexus One (config.mode = "deposit") for all deposit flows. Refer to the nexus-one-deposit agent skill for current integration guidance.
DEPRECATED — The standalone Deposit element (NexusDeposit) has been removed. Use Nexus One (config.mode = "deposit") for all deposit flows. Refer to the nexus-one-deposit agent skill for current integration guidance.
DEPRECATED — FastBridge has been removed. Use Nexus One (config.mode = "swap") for all cross-chain bridge and swap flows. Refer to the nexus-one-swaps agent skill for current integration guidance.
| name | nexus-one-swaps |
| description | Scaffolding, configuration, and integration of the Nexus One component in swap mode (config.mode = "swap"). Handles cross-chain swaps and bridges. |
Use the Nexus One component with config.mode = "swap" to enable users to swap or bridge assets across supported blockchains. Nexus One automatically calculates routes and swaps between exact-in and exact-out flows.
Install dependencies and the component via the shadcn CLI:
npx shadcn@latest add @nexus-elements/nexus-one
Make sure peer dependencies are installed:
npm install @avail-project/nexus-core@1.6.0 decimal.js lucide-react viem wagmi class-variance-authority clsx tailwind-merge
Wrap the component with NexusProvider (usually in your root layout or app provider stack). For provider setup and SDK initialization details, refer to nexus-elements-nexus-provider or the Migration Guide.
import { NexusOne } from "@/components/nexus-one/nexus-one";
export function SwapWidget({ address }: { address?: `0x${string}` }) {
return (
<NexusOne
config={{
mode: "swap",
}}
connectedAddress={address}
/>
);
}
To guide the user's initial selection, you can prefill the source and destination tokens/chains.
0xaf88d065e77c8cC2239327C5EDb3A432268e58310x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913<NexusOne
config={{
mode: "swap",
prefill: {
amount: "100.0", // optional initial amount
source: {
token: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum
chain: 42161,
},
destination: {
token: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base
chain: 8453,
},
},
}}
connectedAddress={address}
/>
Use allowedSourcePairs and allowedDestinationPairs to restrict which networks and tokens users are allowed to interact with.
<NexusOne
config={{
mode: "swap",
allowedSourcePairs: [
{ token: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", chain: 42161 }, // USDC on Arbitrum
{ token: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", chain: 8453 }, // USDC on Base
],
allowedDestinationPairs: [
{ token: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9", chain: 42161 }, // USDT on Arbitrum
]
}}
/>
Use event callbacks to trigger toasts, navigate, or track metrics:
<NexusOne
config={{ mode: "swap" }}
connectedAddress={address}
onStart={() => {
console.log("Transaction flow initiated");
}}
onComplete={(explorerUrl) => {
console.log("Swap completed successfully! Explorer URL:", explorerUrl);
}}
onError={(errorMessage) => {
console.error("Swap flow failed:", errorMessage);
}}
/>
Set embed={false} to render as a modal. You can control the open state or let it be uncontrolled.
// Controlled modal rendering
import { useState } from "react";
export function ControlledSwapModal() {
const [open, setOpen] = useState(false);
return (
<>
<button onClick={() => setOpen(true)}>Open Swap Modal</button>
<NexusOne
config={{ mode: "swap" }}
embed={false}
open={open}
onOpenChange={setOpen}
/>
</>
);
}