Skip to content

Instantly share code, notes, and snippets.

@shirriff
Last active April 7, 2018 00:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save shirriff/f9b3fe82b798ffbb261a to your computer and use it in GitHub Desktop.
Save shirriff/f9b3fe82b798ffbb261a to your computer and use it in GitHub Desktop.
Using the Stratum protocol to connect to a Bitcoin mining pool
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("us1.ghash.io", 3333))
sock.send("""{"id": 1, "method": "mining.subscribe", "params": []}\n""")
print sock.recv(4000)
sock.send("""{"params": ["kens_1", "password"], "id": 2, "method": "mining.authorize"}\n""")
print sock.recv(4000)
@bantic
Copy link

bantic commented Jul 12, 2017

ghash closed down, but you can connect to https://alpereum.zendesk.com/hc/en-us/articles/208552585-Pool-Connection-Info.
Changing line 4 to:

sock.connect(("eu.alpereum.ch", 3002))

worked for me. (But I wasn't able to authorize, obviously).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment