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
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
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.
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.
The EVM transaction to be executed on the destination chain. Exactly one of evm, solana, or transfer must be provided.
The contract's address, or the recipient's address if the transaction is not a contract call.
Value in the smallest unit (ex. wei) to be sent with the transaction.
The encoded calldata for the transaction. Use viem's encodeFunctionData to encode a contract call.
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).
The Solana transaction to be executed on the destination chain. Exactly one of evm, solana, or transfer must be provided.
The base64-encoded Solana transaction message to be executed.
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.
The token to send to the recipient on the destination chain.
The address that will receive the tokens.
The amount to transfer, in a human-readable format.
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.
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.
The commission amount in USD that will be added on top of the transaction cost and will be paid out to the developer.
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.
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.
A Coinbase OAuth access token. When provided, the user's Coinbase account balances are also considered as payment options.
List of CAIP-2 chain IDs to exclude from the returned payment options.
List of currency tiers to exclude from the returned payment options.
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:
The account of the user that will pay for the transaction.
The currency in which the user pays in CAIP-19 format.
The payment amount required for the transaction in the payment currency, in a human-readable format.
The payment amount required for the transaction in USD.
The user's current balance of the payment currency, in a human-readable format.
The user's current balance of the payment currency in USD.
The name of the payment currency.
The symbol of the payment currency.
The URL of the payment currency's logo.
The CAIP-2 chain ID of the chain on which the user pays.
The name of the chain on which the user pays.
The URL of the chain's logo.
The estimated amount required to complete the transaction in the transaction currency.
The currency required by the transaction to be executed, in CAIP-19 format.
The estimated amount required to complete the transaction in USD.
The name of the transaction currency. Ex. "Ethereum".
The symbol of the transaction currency. Ex. "ETH".
The URL of the transaction currency's logo.
The total fee covering the relayer fee and the destination transaction gas cost paid by the relayer, in USD.
Boolean indicating whether the user has sufficient balance to pay for the transaction.