nexus-elements-bridge-deposit
Nexus Elements - Bridge Deposit
Install
- Install widget:
npx shadcn@latest add @nexus-elements/bridge-deposit
- Ensure
NexusProvideris installed and initialized before rendering.
Required setup before rendering
- Ensure
useNexus().nexusSDKis initialized. - Pass connected address (
address) and destination chain (chain). - Provide
depositExecutecallback returning execute parameters.
Initialize SDK (required once per app)
- On wallet connect, resolve an EIP-1193 provider and call
useNexus().handleInit(provider). - Wait for
useNexus().nexusSDKbefore simulation/execution. - Re-run init after reconnect if wallet session resets.
Render widget
"use client";
import BridgeDeposit from "@/components/bridge-deposit/deposit";
import { SUPPORTED_CHAINS, TOKEN_METADATA } from "@avail-project/nexus-core";
import { parseUnits } from "viem";
export function BridgeDepositPanel({ address }: { address: `0x${string}` }) {
return (
<BridgeDeposit
address={address}
chain={SUPPORTED_CHAINS.BASE}
token="USDC"
heading="Deposit USDC"
destinationLabel="Deposit to protocol"
depositExecute={(token, amount, chainId, userAddress) => {
const decimals = TOKEN_METADATA[token].decimals;
const amountWei = parseUnits(amount, decimals);
const contract = "0x0000000000000000000000000000000000000000" as const;
return {
to: contract,
data: "0x",
tokenApproval: {
token,
amount: amountWei,
spender: contract,
},
};
}}
/>
);
}
Live prop contract
- Required:
addresschaindepositExecute(token, amount, chainId, userAddress)
- Optional:
token(defaultUSDC)chainOptions(restrict selectable source chains)heading,embed,destinationLabel
SDK flow details (under the hood)
- Simulation:
- debounced amount triggers
sdk.simulateBridgeAndExecute(...)
- debounced amount triggers
- Execution:
sdk.bridgeAndExecute({ token, amount, toChainId, sourceChains, execute, waitForReceipt: true }, { onEvent })
- Hook usage:
intent.currentfor preview/allowallowance.currentfor allowance decisions
- Event mapping:
NEXUS_EVENTS.STEPS_LISTseeds bridge stepsNEXUS_EVENTS.STEP_COMPLETEmarks progress and transaction start
Source selection behavior
- Widget tracks
inputs.selectedSourcesand passes them to simulate/execute. - Widget blocks simulation/execution if no source chains are selected.
- If you pass
chainOptions, ensure they match chains that actually hold source liquidity.
E2E verification
- Enter amount and confirm simulation response appears.
- Toggle source chains and confirm simulation + fee updates.
- Start transaction and verify intent/allowance flows resolve.
- Verify intent and execute explorer URLs on success.
- Verify balance refresh after completion.
Common failure cases
- No source chains selected:
- widget will error and block execution.
- Invalid execute builder output:
- ensure
to,data, and optionaltokenApprovalare correct.
- ensure
- Simulation fails repeatedly:
- reduce amount or update selected sources.
More from availproject/nexus-elements
nexus-elements-deposit
Integrate the Deposit element for swap-plus-execute deposit flows in React/TypeScript apps. Use when installing or debugging destination-fixed deposits, execute call builders, swap-intent confirmation UX, and `sdk.swapAndExecute` progress from quote to completion.
26nexus-elements-overview
End-to-end integration guide for Nexus Elements in any TypeScript/React codebase. Use when setting up Nexus Elements from scratch, choosing which widget to install, wiring NexusProvider + wallet initialization, or validating bridge/transfer/swap/deposit/history behavior in production-like flows.
24nexus-elements-common
Use shared Nexus Elements hooks, transaction-step helpers, and constants to build custom Nexus UX. Use when extending widgets or implementing custom bridge/transfer/swap/deposit flows that need debouncing, polling, step orchestration, or Nexus error normalization.
23nexus-elements-nexus-provider
Install and configure NexusProvider for Nexus Elements with full SDK lifecycle wiring. Use when setting up or debugging SDK initialization, wallet/provider connection, hook attachment (intent/allowance/swapIntent), balance preloads, exchange-rate support, and provider context consumption in React/TypeScript apps.
23nexus-elements-fast-bridge
Integrate the FastBridge element for intent-based cross-chain bridge UX in React/TypeScript apps. Use when installing or debugging self-bridge flows, source-chain selection, allowance gating, step progress events, and `sdk.bridge` execution end-to-end.
21nexus-elements-unified-balance
Integrate the UnifiedBalance element for cross-chain token balance views in React/TypeScript apps. Use when installing or debugging bridgeable/swappable balance aggregation, per-chain breakdown rendering, and formatting powered by Nexus SDK balance APIs.
21