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

2
  • that seems like a non-reproduceable error. the code looks fine Commented Feb 6, 2018 at 9:40
  • got it even after a restart Commented Feb 6, 2018 at 10:10

1 Answer 1

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))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.