executeTransaction method

Future<BoltPayResponse> executeTransaction()

Implementation

Future<BoltPayResponse> executeTransaction() async {
  String packageId = env == ENV.devnet
      ? BoltPayConstants.devnetPackageId
      : env == ENV.testnet
          ? BoltPayConstants.testnetPackageId
          : BoltPayConstants.mainnetPackageId;

  final gasBudget = BigInt.from(
      10000000); //await suiClient.provider.getReferenceGasPrice();
  int suiAmount = (double.parse(amount) * (1000000000)).toInt();
  final txb = TransactionBlock();
  txb.setGasBudget(gasBudget);

  final coin = txb.splitCoins(txb.gas, [txb.pureInt(suiAmount)]);
  txb.transferObjects([coin], txb.pureAddress(merchantWalletAddress));

  txb.moveCall(
      '$packageId::${BoltPayConstants.module}::${BoltPayConstants.function}',
      arguments: [
        txb.pureInt(int.parse(orderId)),
        txb.pureString(merchantName),
        txb.pureString(BoltPayConstants.poweredBy)
      ]);

  SuiExecuteTransactionResponse suiExecuteTransactionResponse =
      await suiClient.signAndExecuteTransactionBlock(suiAccount, txb);
  return _handleResponse(suiExecuteTransactionResponse);
}