nexus-sdk-bridge-flows
9
总安装量
4
周安装量
#32820
全站排名
安装命令
npx skills add https://github.com/availproject/nexus-sdk --skill nexus-sdk-bridge-flows
Agent 安装分布
opencode
3
codex
3
claude-code
3
gemini-cli
3
replit
2
amp
2
Skill 文档
Bridge and Execute Flows
Call bridge(params, options?)
- Use to move tokens cross-chain (intent-based bridge).
- Signature:
sdk.bridge(params, { onEvent? })
- Params (
BridgeParams):token: stringâ token symbol (e.g., “ETH”, “USDC”)amount: bigintâ smallest unitstoChainId: numberâ destination chain idrecipient?: Hexâ defaults to connected user addressgas?: bigintâ optional native gas to deliver on destinationsourceChains?: number[]â restrict source chains
- Result (
BridgeResult):explorerUrl: stringsourceTxs: { chain, hash, explorerUrl }[]intent: ReadableIntent
Call bridgeAndTransfer(params, options?)
- Use to bridge and transfer to a recipient address.
- Signature:
sdk.bridgeAndTransfer(params, { onEvent? })
- Params (
TransferParams):token: stringamount: biginttoChainId: numberrecipient: HexsourceChains?: number[]
- Result (
TransferResult):transactionHash: stringexplorerUrl: string
Call bridgeAndExecute(params, options?)
- Use to bridge (if needed) and then execute a contract call.
- Signature:
sdk.bridgeAndExecute(params, { onEvent?, beforeExecute? })
- Params (
BridgeAndExecuteParams):token: string,amount: bigint,toChainId: numberexecute: Omit<ExecuteParams, "toChainId">- Optional:
waitForReceipt,requiredConfirmations, timeouts
beforeExecutehook (optional):beforeExecute?: () => Promise<{ value?: bigint; data?: Hex; gas?: bigint }>- Use to dynamically override execute payload before sending.
- Result (
BridgeAndExecuteResult):executeTransactionHash: stringexecuteExplorerUrl: stringbridgeExplorerUrl?: string(undefined if bridge skipped)bridgeSkipped: booleanintent?: ReadableIntent
Call execute(params, options?)
- Use for a standalone contract call on a chain.
- Signature:
sdk.execute(params, { onEvent? })
- Params (
ExecuteParams):toChainId: numberto: Hex(contract address)data?: Hexvalue?: bigintgas?: bigint(optional but recommended for deterministic behavior)gasPrice?: 'low' | 'medium' | 'high'- Optional receipt config:
waitForReceipt,receiptTimeout,requiredConfirmations - Optional
tokenApproval?: { token: string; amount: bigint; spender: Hex }
- Result (
ExecuteResult):transactionHash,explorerUrl,chainId- optional receipt fields
Use simulation helpers
- Call
sdk.simulateBridge(params)âSimulationResult. - Call
sdk.simulateBridgeAndTransfer(params)âBridgeAndExecuteSimulationResult. - Call
sdk.simulateBridgeAndExecute(params)âBridgeAndExecuteSimulationResult. - Use simulation to show fees and gas before execution.
- Expect
BridgeAndExecuteSimulationResult.bridgeSimulationto benullif bridge is skipped.
Compute max bridgeable amount
- Call
sdk.calculateMaxForBridge({ token, toChainId, recipient?, sourceChains? }). - Use
BridgeMaxResultto set âmaxâ or validate input.
Convert amounts to bigint
- Use
sdk.convertTokenReadableAmountToBigInt(amountString, tokenSymbol, chainId). - Or use
sdk.utils.parseUnits(value, decimals)if decimals are known.
Attach hooks and events
- Attach intent and allowance hooks before calling bridge flows.
- Use
NEXUS_EVENTS.STEPS_LISTandNEXUS_EVENTS.STEP_COMPLETEfor progress UI.
Handle common failures
- On throw, clear intent/allowance refs and reset UI state.
- On user cancel, call
deny()on the active hook and abort.