internet-court/internet-court-skill / vendored/sendaifun/squads
squads
VerifiedComplete guide for Squads Protocol - Solana's leading smart account and multisig infrastructure. Covers Squads V4 Multisig for team treasury management, Smart Account Program for account abstraction and programmable wallets, and Grid for stablecoin rails and fintech infrastructure.
| File | Kind | Size |
|---|---|---|
| LICENSE | other | 11.1 KB |
| SKILL.md | skill md | 23.3 KB |
| docs/troubleshooting.md | markdown | 13.7 KB |
| examples/grid/api-quickstart.ts | script | 11.8 KB |
| examples/grid/payments.ts | script | 16.2 KB |
| examples/multisig/create-multisig.ts | script | 9.3 KB |
| examples/multisig/proposals-voting.ts | script | 11.2 KB |
| examples/multisig/spending-limits.ts | script | 11.3 KB |
| examples/multisig/vault-transactions.ts | script | 12.2 KB |
| examples/smart-account/account-creation.ts | script | 10.6 KB |
| examples/smart-account/session-keys.ts | script | 12.5 KB |
| resources/grid-api-reference.md | markdown | 13.5 KB |
| resources/multisig-api-reference.md | markdown | 14.0 KB |
| resources/program-addresses.md | markdown | 6.7 KB |
| resources/smart-account-api-reference.md | markdown | 10.6 KB |
| templates/grid-client.ts | script | 17.0 KB |
| templates/multisig-setup.ts | script | 14.1 KB |
| templates/smart-account-setup.ts | script | 13.4 KB |
examples/grid/api-quickstart.ts
View on GitHub/**
* Squads Grid: API Quickstart Example
*
* This example demonstrates basic Grid API operations for
* stablecoin payments and account management.
*/
// ============================================================================
// CONFIGURATION
// ============================================================================
const CONFIG = {
apiBaseUrl: "https://developer-api.squads.so/api/v1",
apiKey: process.env.GRID_API_KEY || "",
};
// ============================================================================
// TYPES
// ============================================================================
interface GridAccount {
id: string;
email: string;
type: "individual" | "business";
status: "pending_verification" | "active" | "frozen";
address: string;
balances: {
mint: string;
amount: string;
available: string;
pending: string;
}[];
limits: {
daily: { used: string; limit: string };
monthly: { used: string; limit: string };
};
kycStatus: "not_started" | "pending" | "verified" | "failed";
createdAt: string;
}
interface Payment {
id: string;
status: "pending" | "processing" | "completed" | "failed" | "cancelled";
amount: string;
currency: string;
fee: string;
fromAccountId: string;
toAddress: string;
memo?: string;
signature?: string;
createdAt: string;
completedAt?: string;
}
// ============================================================================
// GRID API CLIENT
// ============================================================================
class GridClient {
private baseUrl: string;
private apiKey: string;
constructor(apiKey: string) {
this.baseUrl = CONFIG.apiBaseUrl;
this.apiKey = apiKey;
}
private async request<T>(
endpoint: string,
options: RequestInit = {}
): Promise<T> {
const response = await fetch(`${this.baseUrl}${endpoint}`, {
...options,
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.apiKey}`,
"X-API-Version": "2024-01",
...(options.headers as Record<string, string>),
},
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error?.message || `API error: ${response.status}`);
}
return response.json();
}
// ========================================
// Account Operations
// ========================================
async createAccount(params: {
email: string;
type: "individual" | "business";
metadata?: Record<string, string>;
}): Promise<GridAccount> {
return this.request("/grid/accounts", {
method: "POST",
body: JSON.stringify(params),
});
}
async getAccount(accountId: string): Promise<GridAccount> {
return this.request(`/grid/accounts/${accountId}`);
}
async listAccounts(): Promise<{ accounts: GridAccount[]; total: number }> {
return this.request("/grid/accounts");
}
// ========================================
// Payment Operations
// ========================================
async createPayment(params: {
fromAccountId: string;
toAddress: string;
amount: string;
currency: string;
memo?: string;
idempotencyKey?: string;
}): Promise<Payment> {
return this.request("/grid/payments", {
method: "POST",
body: JSON.stringify(params),
});
}
async getPayment(paymentId: string): Promise<Payment> {
return this.request(`/grid/payments/${paymentId}`);
}
async listPayments(params: {
accountId?: string;
status?: string;
limit?: number;
}): Promise<{ payments: Payment[]; total: number }> {
const queryParams = new URLSearchParams();
if (params.accountId) queryParams.set("accountId", params.accountId);
if (params.status) queryParams.set("status", params.status);
if (params.limit) queryParams.set("limit", params.limit.toString());
return this.request(`/grid/payments?${queryParams.toString()}`);
}
async cancelPayment(paymentId: string): Promise<{ success: boolean }> {
return this.request(`/grid/payments/${paymentId}/cancel`, {
method: "POST",
});
}
}
// ============================================================================
// EXAMPLE FUNCTIONS
// ============================================================================
/**
* Example 1: Create a new Grid account
*/
async function createNewAccount(email: string): Promise<GridAccount> {
console.log("\n=== Creating Grid Account ===");
const client = new GridClient(CONFIG.apiKey);
const account = await client.createAccount({
email,
type: "individual",
metadata: {
source: "api-quickstart-example",
},
});
console.log("Account created:");
console.log(" ID:", account.id);
console.log(" Email:", account.email);
console.log(" Solana Address:", account.address);
console.log(" Status:", account.status);
console.log(" KYC Status:", account.kycStatus);
return account;
}
/**
* Example 2: Get account details and balances
*/
async function getAccountDetails(accountId: string): Promise<void> {
console.log("\n=== Getting Account Details ===");
const client = new GridClient(CONFIG.apiKey);
const account = await client.getAccount(accountId);
console.log("Account:", account.id);
console.log("Status:", account.status);
console.log("Address:", account.address);
console.log("\nBalances:");
account.balances.forEach((balance) => {
console.log(` ${balance.mint}:`);
console.log(` Total: ${balance.amount}`);
console.log(` Available: ${balance.available}`);
console.log(` Pending: ${balance.pending}`);
});
console.log("\nLimits:");
console.log(
` Daily: ${account.limits.daily.used} / ${account.limits.daily.limit}`
);
console.log(
` Monthly: ${account.limits.monthly.used} / ${account.limits.monthly.limit}`
);
}
/**
* Example 3: Make a USDC payment
*/
async function makePayment(
fromAccountId: string,
toAddress: string,
amountUsdc: number
): Promise<Payment> {
console.log("\n=== Making USDC Payment ===");
const client = new GridClient(CONFIG.apiKey);
// Amount in USDC (human readable, API handles conversion)
const payment = await client.createPayment({
fromAccountId,
toAddress,
amount: amountUsdc.toFixed(2),
currency: "USDC",
memo: "Payment via Grid API",
idempotencyKey: `payment-${Date.now()}`, // Prevent duplicate payments
});
console.log("Payment created:");
console.log(" ID:", payment.id);
console.log(" Status:", payment.status);
console.log(" Amount:", payment.amount, payment.currency);
console.log(" Fee:", payment.fee, payment.currency);
console.log(" To:", payment.toAddress);
return payment;
}
/**
* Example 4: Check payment status
*/
async function checkPaymentStatus(paymentId: string): Promise<void> {
console.log("\n=== Checking Payment Status ===");
const client = new GridClient(CONFIG.apiKey);
const payment = await client.getPayment(paymentId);
console.log("Payment:", payment.id);
console.log("Status:", payment.status);
console.log("Amount:", payment.amount, payment.currency);
switch (payment.status) {
case "pending":
console.log("Payment is being processed...");
break;
case "processing":
console.log("Transaction submitted to Solana...");
break;
case "completed":
console.log("Payment successful!");
console.log("Signature:", payment.signature);
console.log("Completed at:", payment.completedAt);
break;
case "failed":
console.log("Payment failed. Check account balance and limits.");
break;
case "cancelled":
console.log("Payment was cancelled.");
break;
}
}
/**
* Example 5: List recent payments
*/
async function listRecentPayments(accountId: string): Promise<void> {
console.log("\n=== Recent Payments ===");
const client = new GridClient(CONFIG.apiKey);
const { payments, total } = await client.listPayments({
accountId,
limit: 10,
});
console.log(`Showing ${payments.length} of ${total} payments:\n`);
payments.forEach((payment, index) => {
console.log(`${index + 1}. ${payment.id}`);
console.log(` Amount: ${payment.amount} ${payment.currency}`);
console.log(` Status: ${payment.status}`);
console.log(` Date: ${payment.createdAt}`);
console.log("");
});
}
/**
* Example 6: Cancel a pending payment
*/
async function cancelPendingPayment(paymentId: string): Promise<void> {
console.log("\n=== Cancelling Payment ===");
const client = new GridClient(CONFIG.apiKey);
// First check if payment is still pending
const payment = await client.getPayment(paymentId);
if (payment.status !== "pending") {
console.log(`Cannot cancel payment with status: ${payment.status}`);
return;
}
await client.cancelPayment(paymentId);
console.log("Payment cancelled successfully");
}
/**
* Example 7: Complete payment flow with retry
*/
async function completePaymentFlow(
fromAccountId: string,
toAddress: string,
amount: number
): Promise<void> {
console.log("\n=== Complete Payment Flow ===");
const client = new GridClient(CONFIG.apiKey);
// Step 1: Check account balance
const account = await client.getAccount(fromAccountId);
const usdcBalance = account.balances.find((b) => b.mint === "USDC");
if (!usdcBalance || parseFloat(usdcBalance.available) < amount) {
throw new Error("Insufficient USDC balance");
}
console.log("Balance check: OK");
// Step 2: Check limits
const dailyRemaining =
parseFloat(account.limits.daily.limit) -
parseFloat(account.limits.daily.used);
if (dailyRemaining < amount) {
throw new Error("Daily limit exceeded");
}
console.log("Limit check: OK");
// Step 3: Create payment
const payment = await client.createPayment({
fromAccountId,
toAddress,
amount: amount.toFixed(2),
currency: "USDC",
idempotencyKey: `flow-${Date.now()}`,
});
console.log("Payment created:", payment.id);
// Step 4: Poll for completion
let attempts = 0;
const maxAttempts = 30;
const pollInterval = 2000; // 2 seconds
while (attempts < maxAttempts) {
const status = await client.getPayment(payment.id);
if (status.status === "completed") {
console.log("Payment completed!");
console.log("Signature:", status.signature);
return;
}
if (status.status === "failed") {
throw new Error("Payment failed");
}
if (status.status === "cancelled") {
throw new Error("Payment was cancelled");
}
console.log(`Status: ${status.status}... waiting`);
await new Promise((resolve) => setTimeout(resolve, pollInterval));
attempts++;
}
throw new Error("Payment timed out");
}
// ============================================================================
// MAIN
// ============================================================================
async function main() {
console.log("=== Squads Grid API Quickstart ===");
if (!CONFIG.apiKey) {
console.log("\nNote: Set GRID_API_KEY environment variable to run examples");
console.log("Get your API key from: https://developers.squads.so\n");
console.log("Grid API Features:");
console.log("1. Create and manage stablecoin accounts");
console.log("2. Send USDC/USDT payments instantly");
console.log("3. Set up recurring payments (standing orders)");
console.log("4. Connect to fiat rails via virtual accounts");
console.log("5. Built-in KYC/AML compliance");
return;
}
try {
// Create a test account
const account = await createNewAccount("test@example.com");
// Get account details
await getAccountDetails(account.id);
// Make a payment (would need funded account)
// const payment = await makePayment(account.id, "RecipientAddress...", 10.00);
// await checkPaymentStatus(payment.id);
// List payments
await listRecentPayments(account.id);
} catch (error) {
console.error("Error:", error);
}
}
main().catch(console.error);
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |