kesar / ethereum-php

Ethereum Client in PHP
103 stars 50 forks source link

list transactions? #9

Open zottirik opened 6 years ago

zottirik commented 6 years ago

Is there any method for list all transactions to coming all accounts, or outgoing from all accounts?

shoxabbos commented 6 years ago

This is the only way to get a list of transactions ))

$blockNumber = $client->eth()->blockNumber();
for ($i = 6000000; $i < $currentBlock; $i++) {
            $blockNumber = new BlockNumber($i);
            $block = $client->eth()->getBlockByNumber($blockNumber);

            /**
             * @var $transaction TransactionHash
             */
            foreach ($block->transactions() as $transaction) {
                echo $transaction->toString();
           }
 }
digitaldonkey commented 6 years ago

You might check out https://github.com/digitaldonkey/ethereum-php-eventlistener if you want to do something alike. Check out the Examples https://github.com/digitaldonkey/ethereum-php-eventlistener/tree/master/app