Skip to content

Create session

Create a new Glide session to make a cross-chain, cross-token, or gasless payment

A Glide session should be created once a user has shown intent to pay for a transaction using Glide.

A session is valid for 10 minutes, during which the user should complete the payment process. If the user does not complete the payment within this time, the session will expire and the user will need to create a new session. If a payment is made for an expired session, the payment will be refunded automatically.

Once a session is created, use the executeSession action to complete the payment process.

Import

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

Usage

Parameters

chainId*
number

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

account
nullable 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
nullable CAIP19 | Currency

The currency in which the user pays in CAIP-19 format. Defaults to the first currency returned by listPaymentOptions.

preferGaslessPayment
nullable boolean

When set to true and if supported by the payment currency, the user will be able to pay with a signature only, requiring no gas. Defaults to false.

address
nullable 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.

walletSecret
nullable string

The wallet secret that was used when creating the wallet. Required if the account wallet was created on Glide.

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.