Skip to content

Create SVM transfer message

Build a Solana transfer message for a session

Builds a base64-encoded Solana transfer message that sends a currency to a recipient. Pass the resulting message as the solana.message parameter of createSession or listPaymentOptions when the destination transaction is a simple Solana transfer.

Import

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

Usage

index.ts
import { createSession, createSVMTransferMessage } from "@paywithglide/glide-js";
import { solana } from "@paywithglide/glide-js/chains";
import { usdc } from "@paywithglide/glide-js/currencies";
import { config } from "./config";
 
const userWalletAddress = "6VxUx4M6heF5g9EDXbCEV3AhtnJhrAxUdz4JXHrX43GB";
 
const { message } = await createSVMTransferMessage(config, {
  chain: solana,
  currency: usdc,
  recipient: "7C4jsPZpht42Tw6MjXWF56Q5RQUocjBBmciEjDa8HRtp",
  amount: "25",
});
 
const session = await createSession(config, {
  chainId: solana.id,
  account: userWalletAddress,
  solana: { message },
});

Parameters

chain*
Chain

The Solana chain, imported from @paywithglide/glide-js/chains.

currency*
Currency

The currency to transfer, imported from @paywithglide/glide-js/currencies.

recipient*
string

The Solana address that receives the transfer.

amount*
string

The amount to transfer, in a human-readable format.

Return Type

message*
string

The base64-encoded Solana transfer message.