sendContract method

Future<Contract> sendContract({
  1. Account? account,
  2. String? passphrase,
})

Implementation

Future<Contract> sendContract({Account? account, String? passphrase}) async {
  try {
    await this.signTxn(account: account, passphrase: passphrase);

    var txnSent = await this.transaction!.sendTransaction();

    var transaction = txnSent!.transaction;
    var result = txnSent.result;

    this.contractAddress = this.contractAddress!.isNotEmpty
        ? this.contractAddress
        : result['ContractAddress'];

    this.transaction = transaction.map((obj) {
      var resultMap = Map.from(obj);
      var newMap = {'TranID': result['TranID']};
      resultMap.addAll(newMap);
      return resultMap;
    });

    this.setStatus(ContractStatus.SENT);

    return this;
  } catch (error) {
    rethrow;
  }
}