Estimate payment amount
Estimate the amount that should be paid for a transaction without creating a session. Since this is only an estimate, the actual amount may vary when a session is created. If you need a firm quote, you should create a session.
Import
import { estimatePaymentAmount } from "@paywithglide/glide-js";
Usage
import { estimatePaymentAmount, currencies, chains } from "@paywithglide/glide-js";
import { config } from "./config";
const estimate = await estimatePaymentAmount(config, {
chainId: chains.base.id,
account: "0xc6FfEB1298Eb33Da430d14e5Eb789256ec344625",
paymentCurrency: currencies.usdc,
abi: fabricAbi,
address: "0x1169c6769c4F4B3cA1944AF0F26B36582fd5279d",
functionName: "mintFor",
args: ["0xc6FfEB1298Eb33Da430d14e5Eb789256ec344625", 999999907200n],
value: 999999907200n,
});
Parameters
The EIP-155 chain ID of the chain where the transaction will be executed.
The wallet address that will be used to pay for the transaction.
The currency in which the user pays in CAIP-19 format.
The contract's ABI.
The contract's address.
The name of the function to be called on the contract.
Arguments to be passed when calling the function.
Value in the smallest unit (ex. wei) to be sent with the transaction.
The commission amount in USD that will be added on top of the transaction cost and will be paid out to the developer.
Return Type
The estimated payment amount required for the transaction in the payment currency.
The currency in which the user pays in CAIP-19 format.
The name of the payment currency.
The symbol of the payment currency.
The URL of the payment currency's logo.
The user's current balance of the payment currency.
The user's current balance of the payment currency in USD.