public async Task MineAndGetReceiptAsync(ulong ping) { var setPingFunction = contract.GetFunction("setPint"); Nethereum.Contracts.Event pongEvent = contract.GetEvent("Pong"); Nethereum.Hex.HexTypes.HexBigInteger estimatedGas = await setPingFunction.EstimateGasAsync(ping); Nethereum.RPC.Eth.DTOs.TransactionReceipt receipt = await setPingFunction.SendTransactionAndWaitForReceiptAsync(userAddress, estimatedGas, null, null, ping); Debug.Log("receipt: " + receipt.TransactionHash + ", blockNum: " + receipt.BlockNumber.Value); var filterInput = pongEvent.CreateFilterInput(new BlockParameter(0), BlockParameter.CreateLatest()); var logs = await pongEvent.GetAllChanges <PongEvent>(filterInput); foreach (Nethereum.Contracts.EventLog <PongEvent> log in logs) { Debug.Log("================================"); Debug.Log("address: " + log.Log.Address); Debug.Log("TransactionHash: " + log.Log.TransactionHash); Debug.Log("blockNum: " + log.Log.BlockNumber); Debug.Log("data: " + log.Log.Data); Debug.Log("Pong: " + log.Event.Pong); } }
public async Task <bool> RentBicycleRequestAndWaitForReceiptAsync(Bicycle rental) { RhodeITDB db = new RhodeITDB(); bool rentalResults = false; RentBicycleFunction rentBicycleFunction = new RentBicycleFunction { BicycleId = rental.ID, DockingStation = rental.DockdeAt, FromAddress = rental.renter, Gas = Variables.gas }; try { Nethereum.RPC.Eth.DTOs.TransactionReceipt transactionReceipt = await ContractHandler.SendRequestAndWaitForReceiptAsync(rentBicycleFunction, null).ConfigureAwait(false); db.StoreTransactionReceipt(new Models.TransactionReceipt { Receipt = transactionReceipt.TransactionHash, Activity = "Rented out bicycle" }); db.StoreUserRide(new Ride { ID = rental.ID, StationName = rental.DockdeAt, Docked = rental.Status, TransactionReceipt = transactionReceipt.TransactionHash }); rentalResults = await UnlockBicycleAsync(rental).ConfigureAwait(false); } catch (Exception e) { Console.WriteLine("Something went wrong bicycle rental: " + e.Message); return(rentalResults); } return(rentalResults); }
public async Task MineAndGetReceiptAsync() { var setPingFunction = contract.GetFunction("setPint"); Nethereum.Contracts.Event pongEvent = contract.GetEvent("Pong"); // var filterAll = await pongEvent.CreateFilterAsync (); // Debug.Log ("filterAll: " + filterAll); // var filter7 = await pongEvent.CreateFilterAsync(7); Nethereum.Hex.HexTypes.HexBigInteger estimatedGas = await setPingFunction.EstimateGasAsync(111); // var transactionHash = await setPingFunction.SendTransactionAsync(address, estimatedGas, null, 8); // Debug.Log ("transactionHash: " + transactionHash); Nethereum.RPC.Eth.DTOs.TransactionReceipt receipt = await setPingFunction.SendTransactionAndWaitForReceiptAsync(address, estimatedGas, null, null, 111); Debug.Log("receipt: " + receipt.TransactionHash + ", blockNum: " + receipt.BlockNumber.Value); // object[] array = new[] { "9" }; var filterInput = pongEvent.CreateFilterInput(new BlockParameter(0), BlockParameter.CreateLatest()); var logs = await pongEvent.GetAllChanges <PongEvent>(filterInput); foreach (Nethereum.Contracts.EventLog <PongEvent> log in logs) { Debug.Log("================================"); Debug.Log("address: " + log.Log.Address); Debug.Log("TransactionHash: " + log.Log.TransactionHash); Debug.Log("blockNum: " + log.Log.BlockNumber); Debug.Log("data: " + log.Log.Data); Debug.Log("Pong: " + log.Event.Pong); } // var log = await pongEvent.GetFilterChanges<PongEvent>(filterAll); // var log7 = await pongEvent.GetFilterChanges<PongEvent>(filter7); Debug.Log("logs: " + logs.Count); // Debug.Log("log: " + log.Count); }
public static string[] GetAllRelatedAddresses(this Transaction tx, TransactionReceipt receipt) { if (tx == null) { return new string[] { } } ; var uniqueAddresses = new UniqueAddressList() { tx.From }; if (tx.To.IsNotAnEmptyAddress()) { uniqueAddresses.Add(tx.To); } if (receipt != null) { if (receipt.ContractAddress.IsNotAnEmptyAddress()) { uniqueAddresses.Add(receipt.ContractAddress); } foreach (var log in tx.GetTransactionLogs(receipt)) { if (log.Address.IsNotAnEmptyAddress()) { uniqueAddresses.Add(log.Address); } } } return(uniqueAddresses.ToArray()); } }
public static bool IsForContractCreation( this Transaction transaction, TransactionReceipt transactionReceipt) { return(transaction.To.IsAnEmptyAddress() && transactionReceipt.ContractAddress.IsNotAnEmptyAddress()); }
public static bool IsContractAddressEqual(this TransactionReceipt receipt, string address) { return(receipt.ContractAddress.EqualsAddress(address)); }
public static bool IsContractAddressEmptyOrEqual(this TransactionReceipt receipt, string contractAddress) { return(receipt.ContractAddress.IsEmptyOrEqualsAddress(contractAddress)); }
public static bool HasLogs(this TransactionReceipt receipt) { return(receipt.Logs?.Count > 0); }
public static bool Failed(this TransactionReceipt receipt) { return(!receipt.Succeeded()); }
public static bool Succeeded(this TransactionReceipt receipt) { return(receipt.Status.Value == BigInteger.One); }
public static bool Failed(this TransactionReceipt receipt, bool treatNullStatusAsFailure = TREAT_NULL_STATUS_AS_FAILURE) { return(receipt.HasErrors() ?? treatNullStatusAsFailure); }
public static bool Succeeded(this TransactionReceipt receipt, bool treatNullStatusAsFailure = TREAT_NULL_STATUS_AS_FAILURE) { return(!receipt.Failed(treatNullStatusAsFailure)); }
public static IEnumerable <FilterLogVO> GetTransactionLogs(this Transaction transaction, TransactionReceipt receipt) { for (var i = 0; i < receipt.Logs?.Count; i++) { if (receipt.Logs[i] is JObject log) { var typedLog = log.ToObject <FilterLog>(); yield return (new FilterLogVO(transaction, receipt, typedLog)); } } }
public FilterLogVO(Transaction transaction, TransactionReceipt receipt, FilterLog log) { Transaction = transaction; Receipt = receipt; Log = log; }
public virtual bool HasLogs() { return(TransactionReceipt?.HasLogs() ?? false); }