Skip to content

Instantly share code, notes, and snippets.

@KevinSmall
Created February 12, 2019 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KevinSmall/59568e5bad5f7430dc9675e854b900ab to your computer and use it in GitHub Desktop.
Save KevinSmall/59568e5bad5f7430dc9675e854b900ab to your computer and use it in GitHub Desktop.
using Nethereum.Web3;
using System;
using System.Threading.Tasks;
using Nethereum.ABI.FunctionEncoding.Attributes;
using System.Numerics;
using Nethereum.RPC.Eth.DTOs;
namespace NethereumSample
{
class Program
{
[Event("Transfer")]
public class TransferEventDTO : IEventDTO
{
[Parameter("address", "_from", 1, true)]
public string From { get; set; }
[Parameter("address", "_to", 2, true)]
public string To { get; set; }
[Parameter("uint256", "_value", 3, false)]
public BigInteger Value { get; set; }
}
public static void Main(string[] args)
{
GetEvents().Wait();
}
public static async Task GetEvents()
{
Console.WriteLine($"Start");
var web3 = new Web3("https://mainnet.infura.io");
var receiverAddress2 = "0x8b88fce7bd28f0157ac6bb37a96723705d9f3123";
var transferEventHandlerAnyContract = web3.Eth.GetEvent<TransferEventDTO>();
BlockParameter fromBlock = new BlockParameter(5561322);
BlockParameter toBlock = new BlockParameter(5561322);
var filterTransferEventsForAllContractsReceiverAddress2 = transferEventHandlerAnyContract.CreateFilterInput<string, string>(null, receiverAddress2, fromBlock, toBlock);
var test = await transferEventHandlerAnyContract.GetAllChanges(filterTransferEventsForAllContractsReceiverAddress2);
Console.WriteLine($"Done. Event count = {test.Count}.");
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment