Pay cross-chain
In this guide, we'll enable our users to make a transaction on a smart contract deployed on one chain using tokens on another chain.
We will use a Farcaster Storage Bot contract that lets users subscribe by paying a small fee in ETH. The contract is deployed on Optimism and has the address 0x511372B44231a31527025a3D273C1dc0a83D77aF
.
In this guide, we'll show how we can let users pay for this subscription using ETH on Base.
Setup
Before you start, make sure you setup the Glide client using the Installation guide.
Submit transaction via Glide
Other chains
In the example above, we're restructing the user to pay with ETH on Base. If you want to allow the user to pay with any other token, you can use its CAIP-19 address.
Currencies
To get the CAIP-19 address for any of the supported tokens, you can use the currencies
object:
import { currencies } from "@paywithglide/glide-js";
const baseUSDCAddress = currencies.usdc.on(chains.base);
// returns "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
List payment options
Instead of hardcoding a payment currency, you can also list all the supported payment options for the user to choose from. Use the listPaymentOptions action to get the list of supported payment options specific to the user's wallet and the transaction.