These are chat archives for Nethereum/Nethereum

5th
Nov 2018
Ala Psa
@alens00_twitter
Nov 05 2018 00:01
I'm trying to get events of the contract but always I try to run GetFilterChanges function on event I get 0 events returned. If I check contract on etherscan there are 3 events. Is there any known bug related to this?

var highestBidIncreasedEvent = contract.GetEvent("HighestBidIncreased");

var filterAll = await highestBidIncreasedEvent.CreateFilterAsync();
var logs = await highestBidIncreasedEvent.GetFilterChanges<HighestBidIncreasedEvent>(filterAll);

logs variable always count 0
Enigmatic
@EnigmaticUnreal_twitter
Nov 05 2018 05:17
@alens00_twitter - I think your case might be because FilterChanges grabs events only after the filter is created, not before. I can drop you a sample code in a few hours, have to run off to another meeting....
Enigmatic
@EnigmaticUnreal_twitter
Nov 05 2018 10:41
        callEvent = tokencontract.GetEvent(Of raiseMeClass)("raiseMe")
        filter = Await callEvent.CreateFilterAsync()

        Dim callfunc = tokencontract.GetFunction("callTest")
        Dim transactionHash As Nethereum.RPC.Eth.DTOs.TransactionReceipt

        transactionHash = Await callfunc.SendTransactionAndWaitForReceiptAsync(account.Address, gas, value, Nothing, 1)
        Debug.Print("Transaction included in block number: " & transactionHash.BlockNumber.Value.ToString & ", transaction hash: " & transactionHash.TransactionHash.ToString)

        transactionHash = Await callfunc.SendTransactionAndWaitForReceiptAsync(account.Address, gas, value, Nothing, 1)
        Debug.Print("Transaction included in block number: " & transactionHash.BlockNumber.Value.ToString & ", transaction hash: " & transactionHash.TransactionHash.ToString)

        transactionHash = Await callfunc.SendTransactionAndWaitForReceiptAsync(account.Address, gas, value, Nothing, 1)
        Debug.Print("Transaction included in block number: " & transactionHash.BlockNumber.Value.ToString & ", transaction hash: " & transactionHash.TransactionHash.ToString)

        transactionHash = Await callfunc.SendTransactionAndWaitForReceiptAsync(account.Address, gas, value, Nothing, 1)
        Debug.Print("Transaction included in block number: " & transactionHash.BlockNumber.Value.ToString & ", transaction hash: " & transactionHash.TransactionHash.ToString)

        ' setting up the filter here instead doesn't do anything for us
        ' filter = Await callEvent.CreateFilterAsync()

        log = Await callEvent.GetFilterChanges(filter) ' get changes
        Debug.Print(log(0).Event.GiveMeValue.ToString)
        Debug.Print(log(0).Event.GiveMeAddress.ToString)
@alens00_twitter - Something like this. Don't mind the VB code though.
Ala Psa
@alens00_twitter
Nov 05 2018 18:39
@EnigmaticUnreal_twitter Thank you, it makes sense. It's working for me now. What would be the best way to somehow subscribe to events, so I get callback when it's called? Would it be good that I call GetFilterChanges for example every 1min? Or is there any better solution to that problem.