Skip to main content
The 1Click SDK provides client libraries in multiple languages for seamless cross-chain token swaps using the 1Click Swap API.

Quickstart

There is no testnet version of NEAR Intents - use small amounts for test swaps.
1

Prerequisites

2

Install SDK package

npm install @defuse-protocol/one-click-sdk-typescript
3

Configure client

import { OpenAPI } from '@defuse-protocol/one-click-sdk-typescript';

// The base URL defaults to https://1click.chaindefuser.com
OpenAPI.BASE = 'https://1click.chaindefuser.com';

// Required for getQuote, submitDepositTx, and getExecutionStatus
OpenAPI.TOKEN = 'YOUR_JWT_TOKEN';
4

Query supported tokens

import { OneClickService } from '@defuse-protocol/one-click-sdk-typescript';

const tokens = await OneClickService.getTokens();
console.log(tokens);
5

Request a quote

import { OneClickService, QuoteRequest } from '@defuse-protocol/one-click-sdk-typescript';

// Example: swap USDC on Arbitrum for USDC on Solana
const quoteRequest: QuoteRequest = {
  dry: false,                                    // true = simulate only, no depositAddress returned
  swapType: QuoteRequest.swapType.EXACT_INPUT,
  slippageTolerance: 100,                        // basis points (100 = 1%)
  originAsset: 'nep141:arb-0xaf88d065e77c8cc2239327c5edb3a432268e5831.omft.near',
  depositType: QuoteRequest.depositType.ORIGIN_CHAIN,
  destinationAsset: 'nep141:sol-5ce3bf3a31af18be40ba30f721101b4341690186.omft.near',
  amount: '1000000',                             // 1 USDC in smallest units (6 decimals)
  refundTo: '0xYourArbitrumAddress',
  refundType: QuoteRequest.refundType.ORIGIN_CHAIN,
  recipient: 'YourSolanaAddress',
  recipientType: QuoteRequest.recipientType.DESTINATION_CHAIN,
  deadline: new Date(Date.now() + 3 * 60 * 1000).toISOString(),
};

const quote = await OneClickService.getQuote(quoteRequest);
Save quote.quote.depositAddress (and quote.quote.depositMemo if present). You will use these for deposit and status checks.
6

Send tokens

Transfer tokens to the depositAddress (on the origin chain) from the quote response. The swap begins automatically upon receipt.Save your transaction hash for optional submission and tracking.
7

Submit transaction hash (optional)

Submitting the transaction hash lets the service detect your deposit faster and start processing sooner.
await OneClickService.submitDepositTx({
  depositAddress: quote.quote.depositAddress!,
  txHash: '0xYourTransactionHash',
});
8

Monitor status

Poll until status reaches a terminal state (SUCCESS, REFUNDED, or FAILED).
const status = await OneClickService.getExecutionStatus(quote.quote.depositAddress!);
console.log(status.status);
StatusDescription
PENDING_DEPOSITAwaiting your token deposit
KNOWN_DEPOSIT_TXDeposit transaction detected
PROCESSINGSwap being executed
SUCCESSTokens delivered to destination address
INCOMPLETE_DEPOSITDeposit below required amount
REFUNDEDSwap failed, funds returned to refund address
FAILEDSwap encountered an error