generateRawTransaction method

Future<RawTransaction> generateRawTransaction(
  1. String accountFrom,
  2. TransactionPayload payload, {
  3. BigInt? maxGasAmount,
  4. BigInt? gasUnitPrice,
  5. BigInt? expireTimestamp,
})

Implementation

Future<RawTransaction> generateRawTransaction(
  String accountFrom,
  TransactionPayload payload,{
  BigInt? maxGasAmount,
  BigInt? gasUnitPrice,
  BigInt? expireTimestamp
}) async {
  final account = await getAccount(accountFrom);
  final chainId = await getChainId();

  maxGasAmount ??= BigInt.from(20000);
  gasUnitPrice ??= BigInt.from(await estimateGasPrice());
  expireTimestamp ??= BigInt.from(DateTime.now().add(const Duration(seconds: 20)).millisecondsSinceEpoch);

  return RawTransaction(
    AccountAddress.fromHex(accountFrom),
    BigInt.parse(account.sequenceNumber),
    payload,
    maxGasAmount,
    gasUnitPrice,
    expireTimestamp,
    ChainId(chainId),
  );
}