Wallet Payments
For users who have a browser wallet installed, paying can be as simple as clicking a button. The SDK connects to their wallet, builds the transaction, gets it signed, submits it to the Solana network, and verifies confirmation, all in a single call. No QR code scanning, no copy-pasting addresses.
Supported wallets: Phantom, Backpack, Solflare.
Basic usage
Section titled “Basic usage”import { Tribe } from "@tribecloud/sdk";
const status = await tribe.sendViaWallet({ mint: "SOL", amount: "0.5", memo: "Order #123",});// status.status — "confirmed" | "pending" | "expired"// status.txSignature — Solana transaction signatureBehind the scenes, sendViaWallet() handles:
- Creating a payment record on the Tribe server
- Connecting to the user’s wallet
- Building and signing the Solana transaction
- Submitting it to the network
- Verifying confirmation
Complete example
Section titled “Complete example”function PayButton({ mint, amount, memo }) { const [status, setStatus] = useState("idle");
if (!tribe.isWalletAvailable()) { return <p>Install a Solana wallet to pay</p>; }
const pay = async () => { setStatus("loading"); try { const result = await tribe.sendViaWallet({ mint, amount, memo }); setStatus(result.status === "confirmed" ? "confirmed" : "error"); } catch (err) { console.error(err); setStatus("error"); } };
return ( <button onClick={pay} disabled={status === "loading"}> {status === "loading" ? "Confirming..." : status === "confirmed" ? "Paid!" : `Pay ${amount} ${mint === "SOL" ? "SOL" : "tokens"}`} </button> );}<button id="pay-btn">Pay 0.1 SOL</button>
<script src="https://api.tribe.utopian.build/sdk.js?site=YOUR_SITE_ID" defer></script><script defer> document.getElementById("pay-btn").addEventListener("click", async () => { try { const result = await Tribe.sendViaWallet({ mint: "SOL", amount: "0.1" }); if (result.status === "confirmed") { alert("Payment confirmed! Tx: " + result.txSignature); } } catch (err) { alert("Payment failed: " + err.message); } });</script>SPL tokens
Section titled “SPL tokens”Accepting SPL tokens like USDC works the same way. Pass the token’s mint address instead of "SOL":
await tribe.sendViaWallet({ mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC amount: "5.00",});Detect available wallets
Section titled “Detect available wallets”To show individual buttons for each wallet the user has installed, detectWallets() gives you that information:
const wallets = tribe.detectWallets();// [{ id: "phantom", name: "Phantom" }, { id: "backpack", name: "Backpack" }]