REIN
Sign inGet started
API reference

rein_spend

rein_spend(recipient, amount_usdc, memo?)

Submit a USDC payment from your vault. The Anchor program validates all active policy rules atomically. On success, a Receipt PDA is created in the same transaction. On failure, the transaction reverts with a typed error.

Parameters

recipientrequired
string
Domain or URL of the payment recipient. Must match an entry in your allowlist if allowlist is configured. Example: 'api.brave.com'
amount_usdcrequired
number
Amount in USDC to transfer. Must be ≤ per_tx_cap_usdc and not push daily total above daily_cap_usdc.
memo
string
Optional description stored in the Receipt PDA. Useful for cost-per-task analytics. Max 100 chars.

Returns

A SpendReceipt object:

typescript
interface SpendReceipt { signature: string; // Solana transaction signature receipt_pda: string; // On-chain Receipt PDA address vault: string; recipient_hash: string; // SHA-256 of recipient domain amount_usdc: number; timestamp: number; // Unix timestamp (on-chain) refunded: boolean; dispute_id: string | null; }

Errors

PolicyViolationError
daily_cap_exceeded · per_tx_cap_exceeded · not_on_allowlist · on_blocklist · policy_paused · policy_expired
StepUpRequiredError
amount_usdc > step_up_threshold. Agent must wait for owner approval via request_step_up or reduce the amount.
InsufficientBalanceError
Vault does not have enough USDC to cover the spend.

Example

typescript
try { const receipt = await rein.spend({ recipient: 'api.perplexity.ai', amount_usdc: 0.05, memo: 'perplexity search — market research task' }); console.log('Paid:', receipt.signature); } catch (err) { if (err instanceof PolicyViolationError) { console.log('Blocked:', err.rule, err.message); } }
rein_balance →rein_history