Skip to content

Execute session

The executeSession action orchestrates the process required to make a cross-chain, cross-token, and gasless payment using Glide. More specifically, it:

  1. Switches the user's wallet to the correct chain.
  2. Triggers the payment transaction using the user's wallet and updates Glide with the transaction hash.
  3. If gasless payment is available, instead of a payment transaction, the user is prompted to sign a message to authorize the payment. The signature is submitted to Glide.
  4. Waits for the Glide session to be completed.
  5. Returns a complete session object.

Import

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

Usage

Parameters

session*
Session

The session object returned from the createSession action.

currentChainId*
number

The EIP-155 chain ID of the chain that the user's wallet is currently connected to.

switchChainAsync*
({chainId: number}) => Promise<unknown>

A function that switches the user's wallet to the specified chain.

sendTransactionAsync*
({chainId: number, to: string, data?: string, value?: bigint}) => Promise<string>

A function that sends a transaction to the specified chain using the user's wallet. Returns the transaction hash.

signTypedDataAsync
nullable (EIP712TypedData) => Promise<string>

A function that signs typed data using the user's wallet. Returns the signature. Used to enable gasless transactions.

Return Type

sessionId*
string
The unique identifier of the session.
expiresAt*
string
The timestamp at which the session will expire. Generally, this will be 10 minutes after the session is created.
expired*
boolean
A boolean indicating whether the session has expired.
paymentStatus*
PaymentStatus
The current status of the payment for the session. The session begins in the unpaid state and transitions to paid when the user completes their payment transaction.
paymentChainId*
CAIP2
The chain id on which the user will pay for the transaction.
paymentChainName*
string
The chain name on which the user will pay for the transaction.
paymentChainLogoUrl*
string
The chain logo URL on which the user will pay for the transaction.
paymentCurrency*
CAIP19
The currency in which the user pays in the CAIP-19 format.
paymentCurrencySymbol*
string
The currency symbol in which the user pays.
paymentCurrencyLogoUrl*
string
The currency logo URL in which the user pays.
paymentAmount*
string
The amount of the payment required by the user to complete the transaction in a human-readable format.
paymentAmountUSD*
string
The amount of the payment required by the user to complete the transaction in USD.
paymentTransactionHash
nullable Hex | null
The hash of the transaction that the user made to complete the payment.
paymentAction*
'signAndSendTransaction' | 'signTypedData'
The action that the user must take to complete the payment.
unsignedTransaction
nullable EVMTransactionResponse | null
The transaction that the user must sign and send to the chain to complete the payment. It is set when the `paymentAction` is set to `signAndSendTransaction`.
unsignedTypedData
nullable PermitTypedData<Hex> | null
The typed data that the user must sign to complete the payment. It is set when the `paymentAction` is set to `signTypedData`.
sponsoredTransactionChainId*
CAIP2
The chain id on which the transaction will be executed.
sponsoredTransactionChainName*
string
The chain name on which the transaction will be executed.
sponsoredTransactionChainLogoUrl*
string
The chain logo URL on which the transaction will be executed.
sponsoredTransactionStatus*
TransactionStatus
The current status of the transaction that Glide is sending to the chain on behalf of the user.
sponsoredTransactionHash
nullable Hex | null
The hash of the transaction that Glide sent to the chain on behalf of the user.
sponsoredTransaction
nullable EVMTransaction | null
The transaction that Glide sent to the chain on behalf of the user.
sponsoredTransactionAmount*
string
The amount required by the sponsored transaction, in a human-readable format.
sponsoredTransactionCurrency*
CAIP19
The currency in which the sponsored transaction is executed, in CAIP-19 format.
sponsoredTransactionCurrencySymbol*
string
The currency symbol in which the sponsored transaction will be executed.
sponsoredTransactionCurrencyLogoUrl*
string
The currency logo URL in which the sponsored transaction will be executed.
sponsoredTransactionAmountUSD*
string
The amount required by the sponsored transaction, in USD.
totalFeeUSD*
string
The total fee covers the relayer fee and the destination transaction gas cost paid by the relayer.