I
I
im_dimas2018-11-07 03:53:50
PHP
im_dimas, 2018-11-07 03:53:50

Best api service for ethereum?

Tell me the best in your opinion api service for working with Ethereum.
I have the following task:
Get a list of all transactions of a certain contract, divide these transactions into incoming and outgoing, from all this calculate the balance, the current number of incoming transactions, and outgoing for each moment of time from the moment of the first transaction to the current time.
I hope I explained it clearly, since I don’t understand the blockchain well.
Or tell me how to adapt the current algorithm, which does not do a very good job.
I do this:
I get a list of all transactions (and there can be up to 50,000 of them, and even at this stage the server may hang or throw a 502 bad gateway error)
Next, I get a list of internal transactions.
Now, having a list of all transactions, I run them in a loop and do the necessary calculations. Inside the loop, I check if the transaction comes from the current address, then I have to cycle through all the transactions that I received in the second paragraph.
In short, the server stupidly cannot cope with so many calculations
.

$limit = 0;
      for($p = 1; $p < 5; $p++) {
      
        
        // ---------------------- получение списка in транзакций ------------------------
        $TRin = file_get_contents("https://api.etherscan.io/api?module=account&action=txlist&address=".$adr."&startblock=".$row['lastblock']."&page=".$p."&endblock=99999999&sort=asc&apikey=".$token); //список транзакций
                
        $TRin = json_decode($TRin);
        if($TRin->status == "0") break;
                
                
        // ---------------------- получение списка out транзакций ------------------------
        $TRout = file_get_contents("https://api.etherscan.io/api?module=account&action=txlistinternal&address=".$adr."&startblock=".$row['lastblock']."&endblock=99999999&sort=asc&apikey=".$token); //список транзакций
        //file_put_contents("test",$TRout);
        $TRout = json_decode($TRout);
        if($TRout->status == "0") break;
        
        foreach($TRin->result as $t) {			
          if($t->value != "0") {
            $totalout += round(($t->value/1000000000000000000),4);
            $count_o++;
          }
          else {
            
            foreach($TRout->result as $tro) {
              if($tro->blockNumber == $t->blockNumber) {
                //file_put_contents("test",$tro->value);
                $totalin += round(($tro->value/1000000000000000000),4);
                $count_i++;
              }
            }
          }
          
          $balance = $totalout-$totalin;
          if($hour == date("H",$t->timeStamp) && $day == date("d",$t->timeStamp)) continue;
          $hour = date("H",$t->timeStamp);
          $day = date("d",$t->timeStamp);
          //тут записываю данные куда нужно. если за date("H",$t->timeStamp) уже бли записаны данные - пропускаю итерацию цикла
        }
      }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2018-11-07
@dimonchik2013

best API - Geth and a raised ether node

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question