new-system-account-with-airdrop.js 387 B

1234567891011121314151617
  1. // @flow
  2. import {Account, Connection} from '@solana/web3.js';
  3. /**
  4. * Create a new system account and airdrop it some lamports
  5. *
  6. * @private
  7. */
  8. export async function newSystemAccountWithAirdrop(
  9. connection: Connection,
  10. lamports: number = 1,
  11. ): Promise<Account> {
  12. const account = new Account();
  13. await connection.requestAirdrop(account.publicKey, lamports);
  14. return account;
  15. }