npm i @stable-pay/handler
The Stablepay handler exposes a method handleTransferRequest
that is built on top of Solana Pay’s createTransaction
. This is an example of how to send a transaction using Stablepay’s handler package.
import { handleTransferRequest } from '@stable-pay/handler';
import {
Connection,
Keypair,
PublicKey,
clusterApiUrl,
Transaction,
sendAndConfirmTransaction,
} from '@solana/web3.js';
import BigNumber from 'bignumber.js';
async function sendUSDC(): Promise<Transaction> {
const connection = new Connection(clusterApiUrl('mainnet-beta'), 'confirmed');
const sender = new PublicKey('');
//stable-pay split wallet
const recipient = new PublicKey('');
const reference = Keypair.generate().publicKey;
const mintCreationFeePayer = Keypair.generate();
return handleTransferRequest(connection, sender, mintCreationFeePayer, {
recipient,
amount: BigNumber(1),
reference,
});
}
sendUSDC().then(async (tx) => {
const connection = new Connection(clusterApiUrl('mainnet-beta'), 'confirmed');
const signer = Keypair.generate();
const signature = await sendAndConfirmTransaction(connection, tx, [signer]);
console.log(signature);
});