import { PaymasterRpc } from 'starknet';// Initialize paymaster with your API keyconst paymaster = new PaymasterRpc({ nodeUrl: 'https://starknet.paymaster.avnu.fi', // or sepolia.paymaster.avnu.fi for testing headers: { 'x-paymaster-api-key': process.env.AVNU_API_KEY },});// Execute any transaction - gas is paid from your creditsconst result = await account.execute(calls, { paymaster: { provider: paymaster, params: { version: '0x1', feeMode: { mode: 'sponsored' } // You sponsor, user pays nothing } }});
Security: Never expose API keys in frontend code. Use a server-side proxy to keep your key safe.
The Portal gives you full visibility into your sponsored transactions.Overview - Total credits, burn rate, runway projection (“credits running out in X months”), unique users reachedAPI key details - Gas consumed (STRK + USD equivalent), success rate, efficiency metrics (avg cost per transaction, per user), funding historyAnalytics - Transaction volume charts, gas cost trends. Filter by time range (7d / 30d / 90d / 1Y) and API key.Explorer - Search transactions by hash or user address. Filter by status (success/reverted). Export to CSV or JSON for reporting.