Paymaster SDK Tutorial (Typescript)

Install the paymaster SDK

npm install @kanalabs/paymaster-sdk
or
yarn add @kanalabs/paymaster-sdk

Initialize SDK with Private Key and projectKey

import { PaymasterSdk } from "@kanalabs/paymaster-sdk";
const sdk = new PaymasterSdk(
  {
    privateKey:
      "user private key", // Optional
  },
  { 
    projectKey: "your project key", 
    network: Network.TESTNET // default MAINNET 
    chain: chainName.Aptos  // default aptos chain
  }
);

Initialize SDK without Private Key

import { PaymasterSdk } from "@kanalabs/paymaster-sdk";
const sdk = new PaymasterSdk({}, { projectKey: testProjectKey, network: Network.TESTNET })

Check If user already whitelisted,

It will return { success: true, message: 'whitelisted' } if already whitelisted.

It will return { success: true, message: 'not whitelisted' } if it is not whitelisted.

To add user to whitelist

It will return { success: true, message: 'Successfully added' } if successfully whitelisted.

It will return { success: true, message: 'already whitelisted' } if user already whitelisted.

Initialize user account

if that account is not available in Aptos mainnet you can initialize account with the following function.

It will return { success: true, message: 'account initialized' } if successfully initialized.

To make sponsored transactons you can build they required payload and pass it to the sponsoredTxn

Paymaster SDK Example Repo

https://github.com/kanalabs/aptos-paymaster-sdk-example

Last updated