Paymaster SDK Tutorial (Typescript)
Install the paymaster SDK
npm install @kanalabs/paymaster-sdk
or
yarn add @kanalabs/paymaster-sdkInitialize 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.
Sponsor Transactions for Aptos
To make sponsored transactons you can build they required payload and pass it to the sponsoredTxn
Sponsor Transactions for Supra
Sponsor Transaction with Sender Auth and Transaction for Aptos
Sponsor Transaction with Sender Auth and Transaction for Supra
Paymaster SDK Example Repo
Last updated