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
    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);
    }