Skip to content

List payment options

Lists the payment options available for a transaction for the user's wallet based on their balance across chains and tokens and the required transaction amount.

Import

import { listPaymentOptions } from "@paywithglide/glide-js";

Usage

index.ts
import { listPaymentOptions } from "@paywithglide/glide-js";
import { base } from "@paywithglide/glide-js/chains";
import { config } from "./config";
import { encodeFunctionData } from "viem";
 
const fabricAbi = [/* your contract's ABI */];
 
const paymentOptions = await listPaymentOptions(config, {
  chainId: base.id,
  account: "0xc6FfEB1298Eb33Da430d14e5Eb789256ec344625",
 
  evm: {
    address: "0x1169c6769c4F4B3cA1944AF0F26B36582fd5279d",
    value: 999999907200n,
    data: encodeFunctionData({
      abi: fabricAbi,
      functionName: "mintFor",
      args: ["0xc6FfEB1298Eb33Da430d14e5Eb789256ec344625", 999999907200n],
    }),
  },
});

Parameters

chainId*
CAIP2

The CAIP-2 chain ID of the chain where the transaction will be executed (e.g., eip155:8453 for Base). Use the id field of a chain imported from @paywithglide/glide-js/chains.

account
nullable string

The wallet address that will be used to pay for the transaction. If set, only the payment options for which the user has a balance will be returned.

evm
nullable object

The EVM transaction to be executed on the destination chain. Exactly one of evm, solana, or transfer must be provided.

address*
Hex

The contract's address, or the recipient's address if the transaction is not a contract call.

value
nullable bigint

Value in the smallest unit (ex. wei) to be sent with the transaction.

data
nullable Hex

The encoded calldata for the transaction. Use viem's encodeFunctionData to encode a contract call.

approval
nullable object

The approval object, required if the transaction requires spending of an ERC-20 token. Contains token (the token's contract address as Hex) and amount (the amount to approve, as bigint in the token's smallest unit).

solana
nullable object

The Solana transaction to be executed on the destination chain. Exactly one of evm, solana, or transfer must be provided.

message*
string

The base64-encoded Solana transaction message to be executed.

transfer
nullable object

A simple token transfer to be executed on the destination chain, instead of a contract call. Exactly one of evm, solana, or transfer must be provided.

token*
string

The token to send to the recipient on the destination chain.

recipient*
string

The address that will receive the tokens.

amount*
string

The amount to transfer, in a human-readable format.

paymentCurrencies
nullable (CAIP19 | Currency)[]

List of payment currencies that should be considered for the transaction, either in the CAIP-19 format or as currency objects imported from @paywithglide/glide-js/currencies. Cannot be used with paymentChainIds.

paymentChainIds
nullable CAIP2[]

List of CAIP-2 chain IDs that should be considered for the transaction. Cannot be used with paymentCurrencies. Defaults to the chains set in the config.

commissionUSD
nullable string

The commission amount in USD that will be added on top of the transaction cost and will be paid out to the developer.

commissionRates
nullable CommissionRates

Commission rates per currency tier (tier1, tier2, tier3) that will be added on top of the transaction cost and paid out to the developer, as a percentage of the transaction amount (e.g., "0.5" = 0.5%). Cannot be used with commissionUSD.

includeInsufficientBalanceOptions
nullable boolean

When set to true, payment options for which the user does not have a sufficient balance are also returned, with hasSufficientBalance set to false. Defaults to false.

coinbaseAccessToken
nullable string

A Coinbase OAuth access token. When provided, the user's Coinbase account balances are also considered as payment options.

excludeChainIds
nullable CAIP2[]

List of CAIP-2 chain IDs to exclude from the returned payment options.

excludeCurrencyTiers
nullable ('tier1' | 'tier2' | 'tier3')[]

List of currency tiers to exclude from the returned payment options.

gasRefuelAmount
nullable string

The amount of native gas currency to send to the user on the destination chain along with the transaction, in a human-readable format.

Return Type

Returns an array of payment options, each with the following fields:

payerAccount
nullable string

The account of the user that will pay for the transaction.

paymentCurrency*
CAIP19

The currency in which the user pays in CAIP-19 format.

paymentAmount*
string

The payment amount required for the transaction in the payment currency, in a human-readable format.

paymentAmountUSD*
string

The payment amount required for the transaction in USD.

balance*
string

The user's current balance of the payment currency, in a human-readable format.

balanceUSD*
string

The user's current balance of the payment currency in USD.

currencyName*
string

The name of the payment currency.

currencySymbol*
string

The symbol of the payment currency.

currencyLogoUrl*
string

The URL of the payment currency's logo.

chainId*
CAIP2

The CAIP-2 chain ID of the chain on which the user pays.

chainName*
string

The name of the chain on which the user pays.

chainLogoUrl*
string

The URL of the chain's logo.

transactionAmount*
string

The estimated amount required to complete the transaction in the transaction currency.

transactionCurrency*
CAIP19

The currency required by the transaction to be executed, in CAIP-19 format.

transactionAmountUSD*
string

The estimated amount required to complete the transaction in USD.

transactionCurrencyName*
string

The name of the transaction currency. Ex. "Ethereum".

transactionCurrencySymbol*
string

The symbol of the transaction currency. Ex. "ETH".

transactionCurrencyLogoUrl*
string

The URL of the transaction currency's logo.

totalFeeUSD*
string

The total fee covering the relayer fee and the destination transaction gas cost paid by the relayer, in USD.

hasSufficientBalance*
boolean

Boolean indicating whether the user has sufficient balance to pay for the transaction.