Paymaster API

const baseUrl = "https://paymaster.kanalabs.io"
const projectKey = process.env.PROJECT_KEY
const network = Network.MAINNET // mainnet
const chain = chainName.Aptos // aptos 
const headers = {
      'Content-Type': 'application/json',
      'api-key': projectKey,
       network: network ?? Network.MAINNET,
       chain: chain ?? chainName.Aptos,
    }

To initialize Aptos account

Note: The address needs to be whitelisted before initializing it

  async initAccount() {
    const url = `${baseUrl}/initAccount`
    const params = { address: "0x0b4b8ef78fb296f89006f1936f01427a3a7e0eadd11dd4998c6bf438a0c8ce6b" }
    try {
      const response = await axios.get(url, { params, headers })
      return response.data
    } catch (error: any) {
      throw error?.data || error
    }
  }

To whitelist an address

To disable user

Note: To stop/pause users from using sponsored txns

To enable user

Note: To resume sponsored txns for a user

Is whitelisted

Note: To check whether an address is already whitelisted or not

Build txn with feepayer : true and send it to /sponsorGas endpoint with api-key it will return { feePayerAddress, feePayerAuth }

Paymaster API Example Repo

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

Last updated