sendTransaction method

Future<TransactionSent?> sendTransaction()

Implementation

Future<TransactionSent?> sendTransaction() async {
  try {
    if (this.signature == null) {
      throw 'The Transaction has not been signed';
    }
    var res = await this
        .messenger!
        .send(RPCMethod.CreateTransaction, this.toPayload);

    if (res.result != null) {
      var result = res.result!.toMap()!;
      var TranID = result['TranID'];
      if (TranID == null) {
        throw 'Transaction fail';
      } else {
        this.transactionID = TranID;
        this.status = TxStatus.Pending;
        return new TransactionSent(this, result);
      }
    } else if (res.error != null) {
      throw res.error!.message!;
    } else
      return null;
  } catch (error) {
    rethrow;
  }
}