Back to docs

Tutorials

Step-by-step guides for building with Styx Stack

EasyPay: Send Crypto via Text

Send SOL or tokens to anyone via SMS/email. No wallet needed to claim!

Beginner10 min
// EasyPay Standalone - No custom programs needed!
import { EasyPayStandalone, LAMPORTS_PER_SOL } from '@styx-stack/sdk';
import { Connection, Keypair } from '@solana/web3.js';

// Setup
const connection = new Connection('https://api.mainnet-beta.solana.com');
const easypay = new EasyPayStandalone(connection);
const sender = Keypair.fromSecretKey(/* your secret key */);

// === CREATE CLAIMABLE PAYMENT ===
const { payment, link } = await easypay.createPayment({
  sender,
  amount: BigInt(0.5 * LAMPORTS_PER_SOL), // 0.5 SOL
  memo: 'Thanks for lunch!',
});

console.log('Payment created!');
console.log('Escrow:', payment.escrow.toBase58());
console.log('Claim URL:', link.url);

// === GENERATE SMS MESSAGE ===
const sms = easypay.generateSmsMessage(link, 'Alice');
console.log('Send this text:', sms.body);
// "Hey! Alice sent you 0.5 SOL on Solana! 
//  Click here to claim: https://styx.cash/claim?..."

// === GENERATE EMAIL (with HTML) ===
const email = easypay.generateEmailMessage(link, 'Alice');
console.log('Email subject:', email.subject);
console.log('Email HTML:', email.html); // Beautiful branded email

// === RECIPIENT CLAIMS (creates stealth wallet) ===
const claimResult = await easypay.claimPayment({
  claimSecret: link.claimSecret,
  escrow: payment.escrow,
});
console.log('Claimed to:', claimResult.recipient.toBase58());

// === OR GASLESS CLAIM (payer covers fees) ===
const gaslessResult = await easypay.claimGasless({
  claimSecret: link.claimSecret,
  escrow: payment.escrow,
  feePayer, // Your service wallet pays gas
});

// === REFUND EXPIRED PAYMENT ===
const refund = await easypay.refundPayment({
  sender,
  escrow: payment.escrow,
});

📚 Related Resources