Get Sponsor Balance

Using this API call we can get a sponsor balance.

import 'dotenv/config';
import { PaymasterUtils } from '@kanalabs/mirai';

(async () => {
   
   // Define the sponsorAddress and chainId
   const sponsorAddress = '0x7305B1a9bDD8247DeB288BC2d271626159cB8c4c'; // bifrost -> 0x8ffdf51ebf23761d762f028a6e1cb88db25a85bf
   const chainId = 80001;
   const apiKey = process.env.PAYMASTER_API_KEY || '';

   // initializating Paymaster service using the apiKey...
   const paymasterService = new PaymasterUtils(apiKey);
   
   // get a sponsor balance using the specified sponsorAddress and chainId
   const response = await paymasterService.getSponsorBalance(sponsorAddress, chainId);

   // Log the get sponsor balance response
   console.log('response', response);
})()

Last updated