Skip to content

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

Parameters

chainId*
number

The EIP-155 chain ID of the chain where the transaction will be executed.

account*
string

The wallet address that will be used to pay for the transaction.

paymentAmount
nullable number

The amount the user wants to pay, denominated in the paymentCurrency, can be set for transactions that support variable payment amounts (ex. p2p transfers).

paymentCurrency*
CAIP19 | Currency

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

address*
string

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

abi
nullable object[]

The contract's ABI.

functionName
nullable string

The name of the function to be called on the contract.

args
nullable unknown[]

Arguments to be passed when calling the function.

value
nullable bigint

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

approval
nullable object

The approval object, required if the transaction requires spending of an ERC-20 token.

token
nullable Hex

The token's contract address that needs to be approved for spending.

amount
nullable bigint

The amount to approve, in the token's smallest unit.

commissionUSD
nullable number

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

chainId*
number

The EIP-155 chain ID of the chain where the transaction will be executed.

chainName*
string

The name of the chain where the transaction will be executed.

chainLogoUrl*
string

The URL of the chain's logo.

paymentAmount*
string

The estimated payment amount required for the transaction in the payment currency.

paymentCurrency*
CAIP19 | Currency

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

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.

balance*
string

The user's current balance of the payment currency.

balanceUSD*
string

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

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.

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.