skills/nexus-sdk-hooks-events/SKILL.md
Configure Nexus SDK intent/allowance/swap intent hooks and event streaming. Use when integrating approval flows, intent previews, or real-time progress events (NEXUS_EVENTS).
npx skillsauth add availproject/nexus-sdk nexus-sdk-hooks-eventsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
sdk.setOnIntentHook(callback).sdk.setOnAllowanceHook(callback).sdk.setOnSwapIntentHook(callback).allow(...) or deny() or the flow will stall.sdk.setOnIntentHook((data) => {
// data: OnIntentHookData
});
allow(): void — continue the flowdeny(): void — reject the flowintent: ReadableIntent — readable intent info for UIrefresh(selectedSources?: number[]): Promise<ReadableIntent> — refresh the intentdata in a ref so UI can call allow()/deny() later.refresh() on an interval (e.g., every 15s) if you show intent details.deny() and clear the ref.sdk.setOnAllowanceHook((data) => {
// data: OnAllowanceHookData
});
allow(decisions): void
decisions must match the number of sources'min', 'max', bigint, or numeric stringdeny(): voidsources: AllowanceHookSources
decisions array in the same order as sources.allow(decisions) to continue, or deny() to cancel.decisions.length === sources.length or the SDK will reject with INVALID_VALUES_ALLOWANCE_HOOK.sdk.setOnSwapIntentHook((data) => {
// data: OnSwapIntentHookData
});
allow(): voiddeny(): voidintent: SwapIntentrefresh(): Promise<SwapIntent>data and show a UI summary.allow() to proceed or deny() to cancel.{ onEvent } in options.NEXUS_EVENTS.STEPS_LIST → BridgeStepType[]NEXUS_EVENTS.STEP_COMPLETE → BridgeStepTypeNEXUS_EVENTS.SWAP_STEP_COMPLETE → SwapStepTypeSTEPS_LIST to seed step trackers.STEP_COMPLETE and SWAP_STEP_COMPLETE to update progress and explorer links.deny() for the active hook and reset UI state.allow()/deny() is called, the intent remains pending.NexusError for known failures.import { NexusError, ERROR_CODES } from '@avail-project/nexus-core'USER_DENIED_INTENT / USER_DENIED_ALLOWANCE / USER_DENIED_INTENT_SIGNATURE:
INVALID_VALUES_ALLOWANCE_HOOK:
decisions length/type and resubmit.SDK_NOT_INITIALIZED / WALLET_NOT_CONNECTED / CONNECT_ACCOUNT_FAILED:
sdk.initialize(...).INVALID_INPUT / INVALID_ADDRESS_LENGTH:
INSUFFICIENT_BALANCE / NO_BALANCE_FOR_ADDRESS:
TOKEN_NOT_SUPPORTED / CHAIN_NOT_FOUND:
QUOTE_FAILED / SWAP_FAILED / RATES_CHANGED_BEYOND_TOLERANCE / SLIPPAGE_EXCEEDED_ALLOWANCE:
RFF_FEE_EXPIRED:
TRANSACTION_TIMEOUT / LIQUIDITY_TIMEOUT:
TRANSACTION_REVERTED:
COSMOS_ERROR / INTERNAL_ERROR:
err.data?.details for support.import { NexusError, ERROR_CODES } from '@avail-project/nexus-core';
export function getReadableNexusError(err: unknown): string {
if (err instanceof NexusError) {
switch (err.code) {
case ERROR_CODES.USER_DENIED_INTENT:
case ERROR_CODES.USER_DENIED_ALLOWANCE:
case ERROR_CODES.USER_DENIED_INTENT_SIGNATURE:
return 'Transaction cancelled by user';
case ERROR_CODES.INSUFFICIENT_BALANCE:
return 'Insufficient balance';
case ERROR_CODES.SLIPPAGE_EXCEEDED_ALLOWANCE:
case ERROR_CODES.RATES_CHANGED_BEYOND_TOLERANCE:
return 'Price changed too much. Please try again.';
case ERROR_CODES.TRANSACTION_TIMEOUT:
return 'Transaction timed out. Please retry.';
default:
return err.message;
}
}
if (err instanceof Error) return err.message;
return 'Unknown error';
}
intentRef.current = null; allowanceRef.current = null; swapIntentRef.current = null;development
Implement swapWithExactIn, swapWithExactOut, and swapAndExecute flows with Nexus SDK. Use when wiring swap operations, swap intent hooks, or swap event progress updates.
development
Set up and initialize Nexus SDK in any JS/TS frontend project. Use when configuring wallet provider, SDK instance lifecycle, network selection, or adding a minimal wallet connection path.
development
End-to-end integration guidance for Avail Nexus SDK in any JS/TS frontend project (React/Next/Vite/etc). Use when asked to integrate, initialize, or wire Nexus SDK flows (bridge, transfer, execute, swap), hooks, events, balances, supported chains/tokens, or formatter utilities.
development
Implement bridge, bridgeAndTransfer, bridgeAndExecute, and execute flows with Nexus SDK. Use when wiring cross-chain bridge and execution operations, simulations, or max-amount checks.