import { ethers } from 'ethers' ; import { deriveSponsorWalletAddress , deriveAirnodeXpub } from '@api3/airnode-admin' ; import { cliPrint , getAirnodeWallet , getProvider , readIntegrationInfo , runAndHandleErrors } from '../src' ; const main = async ( ) => { const integrationInfo = readIntegrationInfo ( ) ; const airnodeWallet = getAirnodeWallet ( ) ; const provider = getProvider ( ) ; const sponsor = ethers . Wallet . fromMnemonic ( integrationInfo . mnemonic ) . connect ( provider ) ; const airnodeXpub = deriveAirnodeXpub ( airnodeWallet . mnemonic . phrase ) ; const sponsorWalletAddress = await deriveSponsorWalletAddress ( airnodeXpub , airnodeWallet . address , sponsor . address ) ; const balance = await sponsor . getBalance ( ) ; const amountToSend = ethers . utils . parseEther ( '0.1' ) ; if ( balance . lt ( amountToSend ) ) throw new Error ( `Sponsor account (${ sponsor . address }) doesn't have enough funds!` ) ; const tx = await sponsor . sendTransaction ( { to : sponsorWalletAddress , value : amountToSend } ) ; await tx . wait ( ) ; const sponsorWalletRawBalance = await provider . getBalance ( sponsorWalletAddress ) ; const sponsorWalletBalance = ethers . utils . formatEther ( sponsorWalletRawBalance ) ; cliPrint . info ( `Successfully sent funds to sponsor wallet address: ${ sponsorWalletAddress }.` ) ; cliPrint . info ( `Current balance: ${ sponsorWalletBalance }` ) ; } ; runAndHandleErrors ( main ) ;