The Solana wallet adapter handles SPL USDC payments on Solana networks.

Quick setup

import { GalliunClient, createSolanaWalletAdapter } from "@galliun/sdk";
import { Connection } from "@solana/web3.js";

const connection = new Connection("https://api.devnet.solana.com");

const client = new GalliunClient({
  baseUrl: "https://api.galliun.com",
  chain: "solana",
  wallet: createSolanaWalletAdapter(solanaSigner, connection),
});

Signer interface

interface SolanaWalletSigner {
  publicKey: PublicKey;
  sendTransaction: (tx: Transaction, connection: Connection) => Promise<string>;
  signMessage?: (message: Uint8Array) => Promise<Uint8Array>;
}

Integrate with @solana/wallet-adapter-react or your preferred Solana wallet.

Built-in SPL USDC payment

createSolanaWalletAdapter(signer, connection) includes built-in SPL USDC transfer. The adapter:

Custom pay override

import { createSolanaWalletAdapterWithPay, payUsdcOnSolana } from "@galliun/sdk";

const wallet = createSolanaWalletAdapterWithPay(solanaSigner, async (option, requirement, signer) => {
  return payUsdcOnSolana(option, signer, connection);
});

Networks

Common networks: devnet, mainnet-beta. Match your wallet network to the 402 accept option.

Message signing

Built-in adapter includes optional signMessage (bs58-encoded). Not required for protected API payments.

Verification

The API Solana adapter verifies:

Common mistakes

Next steps