-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
Hi!
It took me a lot of work to get this part for logging in and getting a response from the pool, but on the mining part I am struggling. If anyone wants to help we can make an ESP code and maybe MINTME can suggest a low difficulty option for mining if they want to of course.
I am doing this in order to support tokens on the MINTME blockchain including my own. Since there is no way to mine tokens normally, if we have any option to mine mintme coins and trade them its still good. Another way would be to make our own mining process where we mine MINTME coins and reward miners with our own token, but I am not sure that would work.
[code]#include <ESP8266WiFi.h>
#include <ArduinoJson.h> // Include ArduinoJson for parsing
#include <Crypto.h> // Include Crypto library
#include <SHA256.h> // Include SHA256 implementation
#include <SHA512.h> // Include SHA512 implementation
// Wi-Fi credentials
const char* ssid = "WiFiName"; // Your Wi-Fi SSID
const char* password = "WiFiPassword"; // Your Wi-Fi password
// Mining pool details
const char* pool_url = "web-ko1.gonspool.com"; // Mining server URL
const int pool_port = 3333; // Mining server port
// Stratum login details
const char* miner_username = "Mintme Wallet Address or Metamask"; // Your mining username. must be from mintme.com or login will fail
const char* miner_password = ""; // Your mining password, always use ""
const char* worker_id = "ESP"; // Worker ID
WiFiClient client;
void setup() {
Serial.begin(9600);
WiFi.begin(ssid, password);
Serial.print("Connecting to Wi-Fi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected to Wi-Fi");
connectToMiningPool();
}
void loop() {
if (client.connected()) {
while (client.available()) {
String response = client.readStringUntil('\n');
Serial.println("Response from pool: " + response);
// Parse response and extract job details
StaticJsonDocument<1024> doc;
DeserializationError error = deserializeJson(doc, response);
if (!error) {
const char* job_id = doc["id"];
const char* job_data = doc["params"][0];
if (job_id && job_data) {
Serial.println("New mining job received:");
Serial.println("Job ID: " + String(job_id));
Serial.println("Job Data: " + String(job_data));
performFakeMiningWork(job_id, job_data);
}
} else {
Serial.println("Error parsing JSON: " + String(error.c_str()));
}
}
} else {
Serial.println("Disconnected from pool, reconnecting...");
delay(5000);
connectToMiningPool();
}
}
void connectToMiningPool() {
if (client.connect(pool_url, pool_port)) {
Serial.println("Connected to mining pool");
sendStratumLogin();
} else {
Serial.println("Failed to connect to pool");
delay(5000);
}
}
void sendStratumLogin() {
String loginRequest = String("{\"id\": 1, \"method\": \"login\", \"params\": {\"login\": \"") +
miner_username + "\", \"pass\": \"" + miner_password +
"\", \"worker_id\": \"" + worker_id + "\"}}\n";
client.print(loginRequest);
Serial.println("Sent login request: " + loginRequest);
}
void performFakeMiningWork(const char* job_id, const char* job_data) {
Serial.println("Processing job...");
// Step 1: SHA256 hash
SHA256 sha256;
byte sha256Hash[32];
sha256.reset();
sha256.update((const byte*)job_data, strlen(job_data));
sha256.finalize(sha256Hash, sizeof(sha256Hash));
// Step 2: SHA512 hash of SHA256 result
SHA512 sha512;
byte sha512Hash[64];
sha512.reset();
sha512.update(sha256Hash, sizeof(sha256Hash));
sha512.finalize(sha512Hash, sizeof(sha512Hash));
// Convert SHA512 result to a string
String sha512String = "";
for (int i = 0; i < sizeof(sha512Hash); i++) {
if (sha512Hash[i] < 0x10) sha512String += "0";
sha512String += String(sha512Hash[i], HEX);
}
Serial.println("Computed hash: " + sha512String);
delay(50);
submitMiningResult(job_id, sha512String);
}
void submitMiningResult(const char* job_id, const String& result) {
String submitRequest = String("{\"id\": 2, \"method\": \"submit\", \"params\": {\"id\": \"") +
job_id + "\", \"result\": \"" + result + "\"}}\n";
client.print(submitRequest);
Serial.println("Submitted result: " + submitRequest);
}[/code]
ArakelTheDragon
Metadata
Metadata
Assignees
Labels
No labels