1

I am doing a PhD in economics and I am currently working on bitcoin. I am trying to understand how senders decide how much fee they include in transactions. Since in a couple decades miners will be rewarded mostly with fees, I think this is an important question. It would be great if I could have data on all the unconfirmed transactions. This would enable me to see, for each transaction, how much fee it includes given the available information, that is how many transactions are already in the mempool and how much fee do those include. Of course I can see those transactions on blockchain.info, for instance, but is there a way I could save them on a file?

Thanks to a very clear video on you tube I can receive the transactions on my browser's console log using blockchain.info's websocket but how can I print, let's say a couple hundred thousands of them, in a textfile?

Could anyone help me? Thank you very much!

2

Simple example, using Python 3 and the websocket-client library.

from websocket import create_connection

ws = create_connection("wss://ws.blockchain.info/inv")
ws.send("""{"op":"unconfirmed_sub"}""")
while True:
    tx = ws.recv()
    print("tx!")
    with open("bitcointx.json", "a") as f:
        f.write(tx + "\n####\n")
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.