public Task <List <TradePost> > GetTrades()
        {
            var transactions = new List <TradePost>();

            foreach (var address in _configuration.Addresses)
            {
                foreach (var transaction in _etherScanClient.GetTransactions(address, sort: "desc").Result)
                {
                    var isSell    = transaction.ToId.ToLowerInvariant() != address.ToLowerInvariant();
                    var brokerage = double.Parse(transaction.gasUsed) * double.Parse(transaction.gasPrice) /
                                    1000000000000000000;
                    var quantity = (double)transaction.Value;
                    if (isSell)
                    {
                        quantity  = (double)transaction.Value + brokerage;
                        brokerage = 0;
                    }
                    transactions.Add(new TradePost
                    {
                        Quantity              = quantity,
                        TransactionDate       = transaction.TimeStamp,
                        Market                = "FX",
                        PortfolioId           = int.Parse(_configuration.PortfolioId),
                        Symbol                = "ETH",
                        BrokerageCurrencyCode = "ETH",
                        TransactionType       = isSell ? "SELL" : "BUY",
                        UniqueIdentifier      = transaction.TxId,
                        Brokerage             = brokerage
                    });
                }
            }

            return(Task.FromResult(transactions));
        }
Beispiel #2
0
        public void Should_Return_TxList()
        {
            var requestNormal = _client.GetTransactions("0x004be92725a0979b9de76ee58330b00bb2f7a82a", 6220000, page: 1, limit: 1000);

            var request = _client.GetInternalTransactions("0x004be92725a0979b9de76ee58330b00bb2f7a82a", 6220000, page: 1, limit: 1000);

            Assert.True(1 == 1);
        }
        public List <Transaction> GetTransaction(string address, int startingblock)
        {
            List <Transaction> listTransactions = new List <Transaction>();

            string APIKEY = "6H3S7JSIPGMQIEE71BCD8AXXK5YCASZE1F";

            try
            {
                //Using EtherScan api for geting transactions
                var etherscan = new EtherScanClient(APIKEY);
                //get all transactions connected with address
                var allTransactions = etherscan.GetTransactions(address);
                if (allTransactions.Result != null)
                {
                    foreach (var item in allTransactions.Result)
                    {
                        //Store only transactions that are happend after starting block
                        if (Convert.ToInt32(item.BlockNumber) >= startingblock)
                        {
                            Transaction _transaction = new Transaction()
                            {
                                TransactionID = item.TxId,
                                AdressFrom    = item.FromId,
                                AdressTo      = item.ToId,
                                HexNumber     = new HexBigInteger(item.BlockNumber),
                                BlockNumber   = item.BlockNumber.ToString(),
                                Value         = item.Value,
                                TimeSpan      = item.TimeStamp.Date
                            };

                            listTransactions.Add(_transaction);
                        }
                    }
                    return(listTransactions);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }