Skip to main content

Overview

Paymasters allow you to sponsor (pay for) transaction fees so users don’t have to worry about gas costs. Starkzap supports two paymaster options depending on your wallet connection strategy.
Use AVNU Paymaster for Privy and Private Key strategies. AVNU provides both gasfree (you sponsor) and gasless (user pays in tokens) modes.

When to Use AVNU Paymaster

  • ✅ Using Privy strategy for wallet connection
  • ✅ Using Private Key strategy (server-side)
  • ✅ Want to sponsor all gas fees for users (gasfree mode)
  • ✅ Want users to pay gas in tokens instead of STRK (gasless mode)
In gasfree mode, your dApp covers all gas costs. This is ideal for:
  • User onboarding flows
  • Premium UX experiences
  • Consumer applications

Setup

1. Get an API Key

Get an API key from the AVNU Portal. This is required for gasfree mode.

2. Configure the SDK

import { StarkZap } from "starkzap";

const sdk = new StarkZap({
  network: "mainnet",
  paymaster: {
    nodeUrl: "https://starknet.paymaster.avnu.fi",
    apiKey: "your-api-key-here", // Required for gasfree mode
  },
});

3. Use Sponsored Transactions

// Execute with sponsored fees
const tx = await wallet.execute([call], { feeMode: "sponsored" });

// Or set as default when connecting
const wallet = await sdk.connectWallet({
  account: { signer },
  feeMode: "sponsored",
});

Propulsion Program

The Starknet Foundation Propulsion Program offers up to $1M in gas subsidies for qualifying projects. This program helps reduce the cost of sponsoring transactions for your users.

Server-Side Paymaster Proxy

For production applications, you may want to proxy paymaster requests through your backend:
// Backend endpoint
app.post("/api/paymaster", async (req, res) => {
  const response = await fetch("https://starknet.paymaster.avnu.fi", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      ...(AVNU_API_KEY && { "x-paymaster-api-key": AVNU_API_KEY }),
    },
    body: JSON.stringify(req.body),
  });
  
  const data = await response.json();
  res.status(response.status).json(data);
});
Then configure the SDK to use your proxy:
const sdk = new StarkZap({
  network: "mainnet",
  paymaster: {
    nodeUrl: "https://your-api.example/paymaster",
  },
});

Best Practices

  1. Use gasfree mode for onboarding and critical user flows
  2. Use gasless mode to let users pay in their preferred tokens
  3. Proxy paymaster requests through your backend in production to keep API keys secure
  4. Monitor usage through the AVNU Portal dashboard
  5. Apply for Propulsion Program if eligible for gas subsidies

Resources

Choosing the Right Paymaster

Use AVNU Paymaster if:
  • You’re using Privy or Private Key strategies
  • You want control over gas sponsorship
  • You need gasless mode (user pays in tokens)
Use Cartridge Paymaster if:
  • You’re using Cartridge Controller strategy
  • You’re building gaming applications
  • You want automatic gasless transactions with zero setup

Next Steps