コード例 #1
0
    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);
        }
    }
コード例 #2
0
ファイル: RhodeITService.cs プロジェクト: Brianspha/Rhode-IT
        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);
        }
コード例 #3
0
    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);
    }
コード例 #4
0
        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());
        }
    }
コード例 #5
0
 public static bool IsForContractCreation(
     this Transaction transaction, TransactionReceipt transactionReceipt)
 {
     return(transaction.To.IsAnEmptyAddress() &&
            transactionReceipt.ContractAddress.IsNotAnEmptyAddress());
 }
コード例 #6
0
 public static bool IsContractAddressEqual(this TransactionReceipt receipt, string address)
 {
     return(receipt.ContractAddress.EqualsAddress(address));
 }
コード例 #7
0
 public static bool IsContractAddressEmptyOrEqual(this TransactionReceipt receipt, string contractAddress)
 {
     return(receipt.ContractAddress.IsEmptyOrEqualsAddress(contractAddress));
 }
コード例 #8
0
 public static bool HasLogs(this TransactionReceipt receipt)
 {
     return(receipt.Logs?.Count > 0);
 }
コード例 #9
0
 public static bool Failed(this TransactionReceipt receipt)
 {
     return(!receipt.Succeeded());
 }
コード例 #10
0
 public static bool Succeeded(this TransactionReceipt receipt)
 {
     return(receipt.Status.Value == BigInteger.One);
 }
コード例 #11
0
 public static bool Failed(this TransactionReceipt receipt, bool treatNullStatusAsFailure = TREAT_NULL_STATUS_AS_FAILURE)
 {
     return(receipt.HasErrors() ?? treatNullStatusAsFailure);
 }
コード例 #12
0
 public static bool Succeeded(this TransactionReceipt receipt, bool treatNullStatusAsFailure = TREAT_NULL_STATUS_AS_FAILURE)
 {
     return(!receipt.Failed(treatNullStatusAsFailure));
 }
コード例 #13
0
        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));
                }
            }
        }
コード例 #14
0
ファイル: FilterLogVO.cs プロジェクト: zzzhangjian/Nethereum
 public FilterLogVO(Transaction transaction, TransactionReceipt receipt, FilterLog log)
 {
     Transaction = transaction;
     Receipt     = receipt;
     Log         = log;
 }
コード例 #15
0
 public virtual bool HasLogs()
 {
     return(TransactionReceipt?.HasLogs() ?? false);
 }