Nexus Widget - Protocol Deposits
Use NexusWidget with config.mode = "deposit" when the app owns the final smart-contract action. Nexus routes funds into one configured destination token/chain and then calls executeDeposit.
For deposit and bridge mode configuration, use the Avail Configurator to generate the exact depositConfig object based on your contract and token setup.
Installation
npm (recommended):
npm install @avail-project/widgets viem wagmi @tanstack/react-queryshadcn (source files):
npx shadcn@latest add availproject/widgets/nexusConfig Shape
Deposit config requires:
destination.chain: supported destination chain id. This is fixed in the UI.destination.tokens: one or more accepted destination tokens. The token selector is limited to this list.depositAddress: smart contract address for the destination action.executeDeposit: transaction builder called as(tokenSymbol, tokenAddress, amount, chainId, user).- Optional
prefill.amount,validation.minAmount,validation.maxAmount, andappearance.
npm:
import { NexusWidget } from "@avail-project/widgets";
import { encodeFunctionData } from "viem";
const DEPOSIT_CONTRACT = "0xYourDepositContract" as const;
const USDT = "0xYourDestinationToken" as const;
const ABI = [
{
inputs: [
{ name: "token", type: "address" },
{ name: "amount", type: "uint256" },
{ name: "user", type: "address" },
],
name: "deposit",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
] as const;
export function DepositWidget({ address }: { address?: `0x${string}` }) {
return (
<NexusWidget
connectedAddress={address}
config={{
mode: "deposit",
destination: {
chain: 42161,
tokens: [
{
address: USDT,
symbol: "USDT",
decimals: 6,
logo: "https://example.com/usdt.svg",
},
],
},
depositAddress: DEPOSIT_CONTRACT,
executeDeposit: (_symbol, tokenAddress, amount, _chainId, user) => ({
to: DEPOSIT_CONTRACT,
gas: 400_000n,
data: encodeFunctionData({
abi: ABI,
functionName: "deposit",
args: [tokenAddress, amount, user],
}),
tokenApproval: {
toTokenAddress: tokenAddress,
amount,
spender: DEPOSIT_CONTRACT,
},
}),
prefill: { amount: "10" },
validation: { minAmount: "1", maxAmount: "1000" },
appearance: {
heading: "Deposit",
appName: "MyProtocol",
appLogoURL: "https://example.com/logo.svg",
mode: "system",
primaryColor: "#0A6BEB",
},
}}
/>
);
}shadcn: Same config, change import to import { NexusWidget } from "@/components/nexus/nexus".
Notes
- Do not use the old
deposit,amountInput,allowedSourcePairs, ordestination.typeconfig fields. prefill.amountmust be greater than0.validation.minAmountmust be0or greater;validation.maxAmountmust be greater than0.appearance.primaryColoraccepts any valid CSS color; the widget chooses readable CTA text automatically.- Use the component prop
onConnectClickto open the host app wallet modal.