createAccount method

Future<Transaction?> createAccount(
  1. CreateAccountOptions options
)

Implementation

Future<Transaction?> createAccount(CreateAccountOptions options) async {
  var appConfig = _ensureAppConfig();
  Commitment commitment = _getCommitment(options.commitment);
  AppConfigMint? mint = _getAppMint(appConfig, options.mint);

  PrepareTransactionResponse blockhash = await _getBlockhash();

  SignedTx tx = await generateCreateAccountTransaction(GenerateCreateAccountOptions(
    addMemo: mint.addMemo,
    blockhash: blockhash.blockhash,
    index: sdkConfig.index,
    lastValidBlockHeight: blockhash.lastValidBlockHeight,
    mintFeePayer: mint.feePayer,
    mintPublicKey: mint.publicKey,
    owner: options.owner,
  ));

  final request = CreateAccountRequest(
    commitment: commitment,
    environment: sdkConfig.environment,
    index: sdkConfig.index,
    lastValidBlockHeight: blockhash.lastValidBlockHeight,
    mint: mint.publicKey,
    referenceId: options.referenceId,
    referenceType: options.referenceType,
    tx: tx.encode(),
  );

  return accountApi.createAccount(request);
}