Create Aptos Sponsored

import 'dotenv/config';
import { NetworkNames, initializeSdkGateway } from '@kanalabs/mirai';
import { randomPrivateKey } from '@etherspot/prime-sdk/dist/sdk/common';

(async () => {
    
    // Generate a random private key for the user
    const key = randomPrivateKey();
    
    // initializating sdk...
    const sdk = await initializeSdkGateway(
        { privateKey: key as string },
        { 
          networks: [NetworkNames.AptosTestnet, NetworkNames.Mumbai], 
          sponsor: process.env.SPONSOR_KEY as string,
          bundlerApiKey: process.env.BUNDLER_API_KEY
        },
      );
    
    // Get the Aptos instance for AptosTestnet
    const apt = sdk.getAptosInstance(NetworkNames.AptosTestnet);
    
    // Create a sponsored account using the Aptos instance's controller and log the result
    console.log(await apt.createAccountSponsored(apt.controller, [], []));
    
    // Log the SmartWallet details
    console.log(await apt.getSmartWalletDetails());
})()

Last updated