Kana Labs Paymaster

To enable gasless transactions via Kana Labs Paymaster, you first need to register your application with Kana Labs and obtain the necessary credentials.

Register with Kana Labs Paymaster Follow the official guide to register your project: How to Register — Kana Labs Paymaster

Integrating Kana Labs Paymaster

After registering with Kana Labs and obtaining your API Key (aka. Secret Key, Project Key), there are two ways to integrate the Paymaster service with the SDK:

1. Direct API Key Injection (Simpler but Less Secure)

You can directly pass the API Key into the SDK configuration to start using the Paymaster service immediately.

  • Pros:

    • Easiest and fastest way to integrate.

    • No backend development effort required.

  • Cons:

    • Security risk: Exposing the API Key on the client-side (e.g., browsers, mobile apps) can lead to key leakage, allowing unauthorized usage and potential depletion of Paymaster funds.

⚠️ Important: Using API keys on the client side is generally not recommended for production environments.

2. Backend Proxy Server (Recommended for Production)

You can build your own backend service to wrap all API requests to Kana Labs' Paymaster API.

  • Pros:

    • Keeps the API Key securely on your server.

    • Allows you to implement additional security checks, rate limiting, and custom authorization layers.

  • Cons:

    • Requires backend infrastructure and additional development effort.

📘 Refer to the official Kana Labs API documentation for implementation details: Kana Labs Paymaster API Documentation

Initialize PKeyWallet with API Key

const WALLET_PRIVATE_KEY = "...";
const KANA_LABS_API_KEY = "...";
const wallet = PKeyWallet.fromPrivateKey(WALLET_PRIVATE_KEY, {
    network: "testnet", // or mainnet
    paymaster: {
        name: 'KANA_LABS',
        options: {
          projectKey: KANA_LABS_API_KEY,
        },
    },
});
// Then send transactions with gas sponsored

Initialize PKeyWallet with wrapper/custom backend

const WALLET_PRIVATE_KEY = "...";
const wallet = PKeyWallet.fromPrivateKey(WALLET_PRIVATE_KEY, {
    network: "testnet", // or mainnet
    paymaster: {
        name: "KANA_LABS",
        options: {
          baseBackendEndpoint: "https://YOUR_BACKEND_DOMAIN/kanalabs-paymaster"
        },
    },
});
// Then send transactions with gas sponsored

Last updated