> ## Documentation Index
> Fetch the complete documentation index at: https://docs.avnu.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Gasfree integration

> Sponsor gas for your users via avnu Portal

Your dApp covers all gas costs. Users transact for free - you pay from your credit balance.

## 1. Sign up

Go to [portal.avnu.fi](https://portal.avnu.fi) and connect your wallet (your account must already be deployed). That's your login - no email/password needed.

<Tip>
  **Team access:** Use a multisig wallet (e.g., Ready 1/X) as your org wallet. Anyone who can sign gets access.
</Tip>

## 2. Create an API key

From the dashboard, create your first API key. Name it something useful (`production`, `staging`, etc.).

<Tip>
  Same key works on Sepolia (free, unlimited) and Mainnet (uses credits). Test on Sepolia first.
</Tip>

| Network | Endpoint                     | Credits                  |
| ------- | ---------------------------- | ------------------------ |
| Sepolia | `sepolia.paymaster.avnu.fi`  | Unlimited (free testing) |
| Mainnet | `starknet.paymaster.avnu.fi` | Real (costs STRK)        |

## 3. Add credits (mainnet only)

Credits are prepaid STRK. They fund your sponsored transactions.

1. Click **Add Credits** on your API key
2. Enter amount in STRK
3. Approve + confirm the transaction
4. Credits appear in \~30 seconds

The dashboard shows burn rate and runway (days until empty).

## 4. Integrate

```typescript theme={null}
import { PaymasterRpc } from 'starknet';

// Initialize paymaster with your API key
const 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 credits
const result = await account.execute(calls, {
  paymaster: {
    provider: paymaster,
    params: {
      version: '0x1',
      feeMode: { mode: 'sponsored' } // You sponsor, user pays nothing
    }
  }
});
```

<Warning>
  **Security:** Never expose API keys in frontend code. Use a server-side proxy to keep your key safe.
</Warning>

### Server-side proxy (Next.js)

```typescript theme={null}
// app/api/paymaster/route.ts
export async function POST(request: Request) {
  const body = await request.json();

  const response = await fetch('https://starknet.paymaster.avnu.fi', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-paymaster-api-key': process.env.AVNU_API_KEY!,
    },
    body: JSON.stringify(body),
  });

  return Response.json(await response.json());
}
```

## Dashboard & analytics

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 reached

**API key details** - Gas consumed (STRK + USD equivalent), success rate, efficiency metrics (avg cost per transaction, per user), funding history

**Analytics** - 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.

### Usage API

```typescript theme={null}
const response = await fetch(
  'https://starknet.api.avnu.fi/paymaster/v1/sponsor-activity?startDate=2025-01-01&endDate=2025-01-31',
  { headers: { 'api-key': process.env.AVNU_API_KEY } }
);

const stats = await response.json();
// { txCount, succeededTxCount, strkGasFees, remainingStrkCredits, ... }
```

<Tip>
  **Low credits?** The dashboard shows runway projection. Check programmatically via the API to automate monitoring.
</Tip>

## Next steps

<CardGroup cols={2}>
  <Card title="Propulsion Program" icon="rocket" href="/docs/paymaster/propulsion-program">
    Get up to \$1M in gas subsidies
  </Card>

  <Card title="Developer support" icon="comments" href="https://t.me/avnu_developers">
    Questions? Join our Telegram
  </Card>
</CardGroup>
