Binance Web3 Connector JS
    Preparing search index...

    Request parameters for buildSwapTransaction operation in TradingApi. BuildSwapTransactionRequest

    interface BuildSwapTransactionRequest {
        amount: string;
        approveAmount?: string;
        approveTransaction?: BuildSwapTransactionApproveTransactionEnum;
        autoSlippage?: BuildSwapTransactionAutoSlippageEnum;
        binanceChainId: string;
        computeUnitLimit?: string;
        computeUnitPrice?: string;
        feePercent?: string;
        fromTokenAddress: string;
        fromTokenReferrerWalletAddress?: string;
        gasLevel?: BuildSwapTransactionGasLevelEnum;
        gasLimit?: string;
        maxAutoSlippagePercent?: string;
        nonce?: string;
        priceImpactProtectionPercent?: string;
        quoteId: string;
        recvWindow?: number | bigint;
        slippagePercent?: string;
        tips?: string;
        toTokenAddress: string;
        toTokenReferrerWalletAddress?: string;
        userWalletAddress: string;
    }
    Index
    amount: string

    Sell-token amount in the token's smallest unit (positive integer string, no decimals).

    TradingApiBuildSwapTransaction

    approveAmount?: string

    Override approve amount (smallest unit, positive integer string). Defaults to the swap amount.

    TradingApiBuildSwapTransaction

    When "true", signatureData includes the spender address and approve calldata so the client can submit it before the swap. Defaults to false.

    TradingApiBuildSwapTransaction

    When "true", slippage is auto-derived from market data and overrides slippagePercent. Either slippagePercent or autoSlippage=true must be provided — omitting both returns a parameter error. Defaults to "false".

    TradingApiBuildSwapTransaction

    binanceChainId: string

    Unique chain identifier (e.g. "56"=BSC, "1"=Ethereum, "CT_501"=Solana).

    TradingApiBuildSwapTransaction

    computeUnitLimit?: string

    Solana only — maximum compute units the transaction may consume (analogous to EVM gasLimit). Applies only when binanceChainId=CT_501.

    TradingApiBuildSwapTransaction

    computeUnitPrice?: string

    Solana only — priority fee per compute unit (micro-lamports), analogous to EVM gasPrice. When omitted, the platform computes a value dynamically. Applies only when binanceChainId=CT_501.

    TradingApiBuildSwapTransaction

    feePercent?: string

    Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be paired with exactly one of fromTokenReferrerWalletAddress or toTokenReferrerWalletAddress (the two referrer addresses are mutually exclusive).

    Range by chain:* (0, 5] for EVM chains (BSC, Ethereum, Base, etc.) and (0, 10] for Solana (CT_501) — greater than 0, up to the chain-specific maximum inclusive, max 2 decimal places. "1.5" means 1.5%. Values exceeding 2 decimal places are rejected with INVALID_FEE_PERCENT (40466).

    four.meme tokens are not supported* — do not pass fee parameters when either side of the pair is a four.meme token.

    TradingApiBuildSwapTransaction

    fromTokenAddress: string

    Sell-token contract address.

    TradingApiBuildSwapTransaction

    fromTokenReferrerWalletAddress?: string

    Wallet address that receives the fee deducted from the sell token (FROM_TOKEN direction). Mutually exclusive with toTokenReferrerWalletAddress — providing both returns CONFLICT_REFERRER_PARAMS (40468). Address format depends on the chain: EVM chains require 0x + 40 hex chars; Solana (CT_501) requires a Base58 pubkey. An invalid format returns INVALID_REFERRER_ADDRESS (40467). Must be paired with feePercent.

    TradingApiBuildSwapTransaction

    Gas price tier. Defaults to "average".

    TradingApiBuildSwapTransaction

    gasLimit?: string

    Gas limit override (positive integer string). EVM only.

    TradingApiBuildSwapTransaction

    maxAutoSlippagePercent?: string

    Cap on auto-derived slippage (only applies when autoSlippage=true).

    TradingApiBuildSwapTransaction

    nonce?: string

    Unique request identifier for anti-replay; falls back to X-OC-SIGN if omitted.

    TradingApiBuildSwapTransaction

    priceImpactProtectionPercent?: string

    Maximum allowed price impact percentage (0–100). Defaults to 90; set to 100 to disable.

    TradingApiBuildSwapTransaction

    quoteId: string

    quoteId returned from /quote for the route to execute. TTL ~30s; expired entries return QUOTE_EXPIRED (40401).

    TradingApiBuildSwapTransaction

    recvWindow?: number | bigint

    Allowed time deviation in milliseconds (default: 5000, max: 60000).

    TradingApiBuildSwapTransaction

    slippagePercent?: string

    Maximum slippage tolerance as a percentage string. Required unless autoSlippage=true.

    Range by chain:*

    • EVM chains (BSC, Ethereum, Base, etc.): 0 to 100 (inclusive)
    • Solana (CT_501): 0 to less than 100 (i.e. < 100)

    Range by vendor:*

    • 1inch, PancakeSwap: 0 to 50 (values above 50 are rejected)
    • LiFi, LiquidMesh: 0 to 100 (EVM) or 0 to < 100 (Solana)
    • Jupiter (Solana): 0 to less than 100; the value is converted to basis points (slippageBps = ceil(slippagePercent × 100)) and applied to the on-chain swap

    "0.5" means 0.5% maximum slippage. When autoSlippage=true this field is overridden by the auto-computed value.

    TradingApiBuildSwapTransaction

    tips?: string

    Solana only — Jito tips in SOL for MEV protection. Valid range [0.000000001, 2] (minimum 1 lamport). When specified, it is recommended to set computeUnitPrice=0. Applies only when binanceChainId=CT_501.

    TradingApiBuildSwapTransaction

    toTokenAddress: string

    Buy-token contract address.

    TradingApiBuildSwapTransaction

    toTokenReferrerWalletAddress?: string

    Wallet address that receives the fee deducted from the buy-token output (TO_TOKEN direction). Mutually exclusive with fromTokenReferrerWalletAddress — providing both returns CONFLICT_REFERRER_PARAMS (40468). Address format depends on the chain: EVM chains require 0x + 40 hex chars; Solana (CT_501) requires a Base58 pubkey. An invalid format returns INVALID_REFERRER_ADDRESS (40467). Must be paired with feePercent. On Solana, the referrer must already be activated (funded with some SOL) or the request returns REFERRER_NOT_ACTIVATED (40469).

    TradingApiBuildSwapTransaction

    userWalletAddress: string

    User wallet address (transaction sender).

    TradingApiBuildSwapTransaction