示例#1
0
        private async Task NotifyEyEmail(Transaction transactions, NotificationModel user, string to, BigInteger value)
        {
            string tokenSymbol = "Ether";

            if (TokenSignature.IsTransfer(transactions.Input))
            {
                var contract = _web3.Eth.GetContract(TokenSignature.StandartABI, transactions.To);

                tokenSymbol = _tokenSignature.GetTokenSymbol(contract).Result;
            }

            await _emailSender.SendEmailAsync(user.Email, "Guapcoin Notification Service",
                                              "Guapcoin\n\n"
                                              + $"You received {_unitConversion.FromWei(value)} {tokenSymbol}, in your address {to}.\n\n"
                                              + "For detailed information please open this link: "
                                              + $"https://ropsten.etherscan.io/tx/{transactions.TransactionHash}\n\n");
        }
示例#2
0
        private async Task ProcessBlockNumber(BigInteger newBlock)
        {
            var transactions = await _web3.Eth.Blocks.GetBlockWithTransactionsByNumber
                               .SendRequestAsync(new HexBigInteger(newBlock));

            if (transactions != null)
            {
                foreach (var it in transactions.Transactions)
                {
                    if (string.IsNullOrEmpty(it.To))
                    {
                        continue;
                    }

                    string     to;
                    BigInteger value;

                    if (TokenSignature.IsTransfer(it.Input))
                    {
                        to    = TokenSignature.TransferTo(it.Input);
                        value = TokenSignature.TransferValue(it.Input);
                    }
                    else
                    {
                        to    = it.To;
                        value = it.Value.Value;
                    }

                    if (Addresses.TryGetValue(new HexBigInteger(to).Value, out var notifData))
                    {
                        if (notifData.NotificationsEnabled)
                        {
                            await NotifyEyEmail(it, notifData, to, value);
                        }
                    }
                }
            }
        }