sendEth function

Future<String> sendEth({
  1. required Account account,
  2. required String password,
  3. required Felt recipientAddress,
  4. required double amount,
  5. dynamic onSendTransactionCallback(
    1. String
    )?,
})

Implementation

Future<String> sendEth({
  required Account account,
  required String password,
  required s.Felt recipientAddress,
  required double amount,
  Function(String)? onSendTransactionCallback,
}) async {
  // final privateKey = await ss.PasswordStore()
  //     .getPrivateKey(id: account.id.toString(), password: password);
  final privateKey = s.Felt.fromHexString("0x1");

  s.StarkAccountSigner? signer =
      s.StarkAccountSigner(signer: s.StarkSigner(privateKey: privateKey));

  final provider = WalletKit().provider;
  final chainId = WalletKit().chainId;

  final fundingAccount = s.Account(
    provider: provider,
    signer: signer,
    accountAddress: s.Felt.fromHexString(account.address),
    chainId: chainId,
  );

  final txHash = await fundingAccount.send(
    recipient: recipientAddress,
    amount: s.Uint256(
      low: s.Felt(
        BigInt.from(amount * 1e18),
      ),
      high: s.Felt.zero,
    ),
  );

  // set signer to null to avoid storing the private key in memory
  signer = null;

  return txHash;
}