public async Task Start() { var contract = _client.GetContract(_abi, _contractAddress); _event = contract.GetEvent(_eventName); _filter = await _event.CreateFilterAsync(); }
private async Task IndexEventsInRange(string coinAdapterAddress, Nethereum.Contracts.Event coinCashInEvent, BigInteger from, BigInteger to) { var fromBlock = new Nethereum.RPC.Eth.DTOs.BlockParameter(new Nethereum.Hex.HexTypes.HexBigInteger(from)); var toBlock = new Nethereum.RPC.Eth.DTOs.BlockParameter(new Nethereum.Hex.HexTypes.HexBigInteger(to)); var filter = await coinCashInEvent.CreateFilterBlockRangeAsync(fromBlock, toBlock); var filterByCaller = await coinCashInEvent.GetAllChanges <CoinCashinEvent>(filter); filterByCaller.ForEach(async @event => { string transactionHash = @event.Log.TransactionHash; CoinEventCashinCompletedMessage cashinTransactionMessage = new CoinEventCashinCompletedMessage() { TransactionHash = transactionHash }; await _cashinEventRepository.InsertAsync(new CashinEvent() { CoinAdapterAddress = coinAdapterAddress, Amount = @event.Event.Amount.ToString(), TransactionHash = transactionHash, UserAddress = @event.Event.Caller }); await _cashinQueue.PutRawMessageAsync(Newtonsoft.Json.JsonConvert.SerializeObject(cashinTransactionMessage)); }); await _blockSyncedRepository.InsertAsync(new BlockSynced() { BlockNumber = to.ToString(), CoinAdapterAddress = coinAdapterAddress }); }