1

What I'm trying to do is to iterate over all blocks in blockchain and print out the transactions. Here is my code so far:

from chainscan import iter_blocks
for block in iter_blocks():
    if block.height > 10: break
    for tx in block.txs:
        print('Hello, tx %s in block %s' % (tx, block))

The problem is that I get the following error:

  File "<ipython-input-3-06037b89d550>", line 1
    for block in iter_blocks():
                               ^
SyntaxError: unexpected EOF while parsing

I already read similar topics like: this or this, but they weren't helpful. Is the problem maybe that the blockchain itself isn't found yet by the block iterator? If it is the case, how can I solve it? Thanks in advance

Jürgen K.
  • 3,427
  • 9
  • 30
  • 66

1 Answers1

1

Looks like you indentation is off. Just copy-paste the following code, and it should work:

from chainscan import iter_blocks
for block in iter_blocks():
    if block.height > 10: break
    for tx in block.txs:
        print('Hello, tx %s in block %s' % (tx, block))
YinYang16
  • 461
  • 3
  • 5