Write NiceHash bot, make lots of profit

News updates about the Prohashing pool
User avatar
Steve Sokolowski
Posts: 2138
Joined: Wed Aug 27, 2014 3:27 pm
Location: State College, PA
Contact:

Write NiceHash bot, make lots of profit

Postby Steve Sokolowski » Mon Jul 18, 2016 8:19 am

Good morning!

We're proud to finally document our WAMP API, which allows users to obtain live statistics about the status of the pool. In the coming days, we also plan to provide methods that provide insight into users' workers and balances.

The first methods are now available at https://prohashing.com/help.html#api-wamp.

For the first time, these methods make it possible for a user to write a "NiceHash bot." Since NiceHash provides an API with all the necessary properties and methods, a bot can be written to obtain pricing at NiceHash, compare it to profits provided by the WAMP API here, and if profit here is greater, then buy lots of hashrate from NiceHash and direct it here.

If programmed conservatively, this bot should never be at risk of losing money. During times of high profitability, profits here often soar to 33% above NiceHash. That should never happen, because a bot like this can drive a significant portion of NiceHash's hashrate here during those times up to the point that NiceHash's rate equalizes.

Is anyone interested in writing this bot? We aren't asking for any cut of the profits that you earn; we just want someone to write it and run it to make themselves money so that we can take the pool fees. GenTarkin seems to have the expertise to make a lot of profit by doing this.
JoeTheMiner
Posts: 62
Joined: Wed Nov 19, 2014 10:30 am

Re: Write NiceHash bot, make lots of profit

Postby JoeTheMiner » Sat Jul 23, 2016 5:45 pm

Steve,

I have an existing NiceHash Bot and am interested in integrating this in it. I tried connecting to the WAMP API using Javascript but it doesn't seem to be returning anything for the f_all_profitability_updates function. I have never programmed using WAMP before and might be making a mistake. Maybe you can point me in the right direction? Looking at the sample Autobahn code, I initiate the connection but what realm should I use? Is the URL to connect to 'wss://live.prohashing.com:443/ws' or 'ws://live.prohashing.com:443/ws'?

Here is the nodejs code I am using;

Code: Select all

var autobahn=require('autobahn');

var connection = new autobahn.Connection({url: 'wss://live.prohashing.com:443/ws'});

connection.onopen = function (session) {
   console.log("Connection opened.");

   // 1) subscribe to a topic
   session.subscribe('profitability_updates', onevent);
   function onevent(args) {
        console.log("Event:", args[0]);
   }

   // 2) call a remote procedure
   session.call('f_all_profitability_updates').then(
        function (res) {
             console.log("Result:", res);
        }
   );
};

connection.open();
console.log("Opening Connection...");


Any pointers are appreciated.

Thanks,
Joseph
User avatar
Steve Sokolowski
Posts: 2138
Joined: Wed Aug 27, 2014 3:27 pm
Location: State College, PA
Contact:

Re: Write NiceHash bot, make lots of profit

Postby Steve Sokolowski » Sat Jul 23, 2016 11:11 pm

JoeTheMiner wrote:Steve,

I have an existing NiceHash Bot and am interested in integrating this in it. I tried connecting to the WAMP API using Javascript but it doesn't seem to be returning anything for the f_all_profitability_updates function. I have never programmed using WAMP before and might be making a mistake. Maybe you can point me in the right direction? Looking at the sample Autobahn code, I initiate the connection but what realm should I use? Is the URL to connect to 'wss://live.prohashing.com:443/ws' or 'ws://live.prohashing.com:443/ws'?

Here is the nodejs code I am using;

Code: Select all

var autobahn=require('autobahn');

var connection = new autobahn.Connection({url: 'wss://live.prohashing.com:443/ws'});

connection.onopen = function (session) {
   console.log("Connection opened.");

   // 1) subscribe to a topic
   session.subscribe('profitability_updates', onevent);
   function onevent(args) {
        console.log("Event:", args[0]);
   }

   // 2) call a remote procedure
   session.call('f_all_profitability_updates').then(
        function (res) {
             console.log("Result:", res);
        }
   );
};

connection.open();
console.log("Opening Connection...");


Any pointers are appreciated.

Thanks,
Joseph


You should use wss://, since this is an encrypted connection.

There isn't anything that immediately comes to mind. After I wake up, I'll give this code a proper review and get back to you.

See you in 12 hours!
JoeTheMiner
Posts: 62
Joined: Wed Nov 19, 2014 10:30 am

Re: Write NiceHash bot, make lots of profit

Postby JoeTheMiner » Sat Jul 23, 2016 11:18 pm

Steve Sokolowski wrote:
JoeTheMiner wrote:Steve,

I have an existing NiceHash Bot and am interested in integrating this in it. I tried connecting to the WAMP API using Javascript but it doesn't seem to be returning anything for the f_all_profitability_updates function. I have never programmed using WAMP before and might be making a mistake. Maybe you can point me in the right direction? Looking at the sample Autobahn code, I initiate the connection but what realm should I use? Is the URL to connect to 'wss://live.prohashing.com:443/ws' or 'ws://live.prohashing.com:443/ws'?

Here is the nodejs code I am using;

Code: Select all

var autobahn=require('autobahn');

var connection = new autobahn.Connection({url: 'wss://live.prohashing.com:443/ws'});

connection.onopen = function (session) {
   console.log("Connection opened.");

   // 1) subscribe to a topic
   session.subscribe('profitability_updates', onevent);
   function onevent(args) {
        console.log("Event:", args[0]);
   }

   // 2) call a remote procedure
   session.call('f_all_profitability_updates').then(
        function (res) {
             console.log("Result:", res);
        }
   );
};

connection.open();
console.log("Opening Connection...");


Any pointers are appreciated.

Thanks,
Joseph


You should use wss://, since this is an encrypted connection.

There isn't anything that immediately comes to mind. After I wake up, I'll give this code a proper review and get back to you.

See you in 12 hours!


Sounds good. Appreciate it.
User avatar
Steve Sokolowski
Posts: 2138
Joined: Wed Aug 27, 2014 3:27 pm
Location: State College, PA
Contact:

Re: Write NiceHash bot, make lots of profit

Postby Steve Sokolowski » Sun Jul 24, 2016 8:51 am

JoeTheMiner wrote:Steve,

I have an existing NiceHash Bot and am interested in integrating this in it. I tried connecting to the WAMP API using Javascript but it doesn't seem to be returning anything for the f_all_profitability_updates function. I have never programmed using WAMP before and might be making a mistake. Maybe you can point me in the right direction? Looking at the sample Autobahn code, I initiate the connection but what realm should I use? Is the URL to connect to 'wss://live.prohashing.com:443/ws' or 'ws://live.prohashing.com:443/ws'?

Here is the nodejs code I am using;

Code: Select all

var autobahn=require('autobahn');

var connection = new autobahn.Connection({url: 'wss://live.prohashing.com:443/ws'});

connection.onopen = function (session) {
   console.log("Connection opened.");

   // 1) subscribe to a topic
   session.subscribe('profitability_updates', onevent);
   function onevent(args) {
        console.log("Event:", args[0]);
   }

   // 2) call a remote procedure
   session.call('f_all_profitability_updates').then(
        function (res) {
             console.log("Result:", res);
        }
   );
};

connection.open();
console.log("Opening Connection...");


Any pointers are appreciated.

Thanks,
Joseph


Hi Joe,

Good morning. I looked into this problem and I discovered that there was an error in the documentation. You do have to use authentication, because there will be future writable methods that are secured for individual users (like getting payout information).

The username and password for the read-only methods is public and is published below. The following code demonstrates how to connect using authentication.

Code: Select all

   var wampUser = 'web';
   var wampPassword = wampUser;               
   
   function onChallenge(wampSession, method, extra) {
      if (method == 'wampcra') {
         return autobahn.auth_cra.sign(wampPassword, extra.challenge);
      }
   };
   
   function connectionOpen(session, details) {
      wampSession = session;
   };
   
   wampConnection = new autobahn.Connection({
      url : 'wss://prohashing.com:444/ws',
      realm : 'mining',
      authmethods: ['wampcra'],
      authid: wampUser,
      onchallenge: onChallenge
   });
   
   wampConnection.onopen = connectionOpen;
   wampConnection.open();


Notice the requirement for the "challenge" functions. You can add them to your code unchanged. The documentation will be updated during the next release to correct the errors and include this code.

There is someone else who is also interested in this idea and has money to seed the bot with. Perhaps you might consider working with him. Please send me a private message if you are interested in that.
JoeTheMiner
Posts: 62
Joined: Wed Nov 19, 2014 10:30 am

Re: Write NiceHash bot, make lots of profit

Postby JoeTheMiner » Sun Jul 24, 2016 10:12 pm

Steve,

Thanks for the update. I tried this code with your authentication methods added and I tried both "wss://prohashing.com:444/ws" and "wss://live.prohashing.com:443/ws" and it still does not appear to be connecting.

Here is the code I tried now.

Code: Select all

var autobahn=require('autobahn');
var wampUser = 'web';
var wampPassword = wampUser;

function onChallenge(wampSession, method, extra) {
  if (method == 'wampcra') {
    return autobahn.auth_cra.sign(wampPassword, extra.challenge);
  }
};

var connection = new autobahn.Connection({
   url: 'wss://prohashing.com:444/ws',
   realm : 'mining',
   authmethods: ['wampcra'],
   authid: wampUser,
   onchallenge: onChallenge
});

connection.onopen = function (session) {
   console.log("Connection opened.");

   // 1) subscribe to a topic
   session.subscribe('profitability_updates', onevent);
   function onevent(args) {
        console.log("Event:", args[0]);
   }

   // 2) call a remote procedure
   session.call('f_all_profitability_updates').then(
        function (res) {
             console.log("Result:", res);
        }
   );
};

connection.open();
console.log("Opening Connection...");


Any ideas now on what might be the problem?

Thanks!
User avatar
Steve Sokolowski
Posts: 2138
Joined: Wed Aug 27, 2014 3:27 pm
Location: State College, PA
Contact:

Re: Write NiceHash bot, make lots of profit

Postby Steve Sokolowski » Mon Jul 25, 2016 9:39 am

JoeTheMiner wrote:Steve,

Thanks for the update. I tried this code with your authentication methods added and I tried both "wss://prohashing.com:444/ws" and "wss://live.prohashing.com:443/ws" and it still does not appear to be connecting.

Here is the code I tried now.

Code: Select all

var autobahn=require('autobahn');
var wampUser = 'web';
var wampPassword = wampUser;

function onChallenge(wampSession, method, extra) {
  if (method == 'wampcra') {
    return autobahn.auth_cra.sign(wampPassword, extra.challenge);
  }
};

var connection = new autobahn.Connection({
   url: 'wss://prohashing.com:444/ws',
   realm : 'mining',
   authmethods: ['wampcra'],
   authid: wampUser,
   onchallenge: onChallenge
});

connection.onopen = function (session) {
   console.log("Connection opened.");

   // 1) subscribe to a topic
   session.subscribe('profitability_updates', onevent);
   function onevent(args) {
        console.log("Event:", args[0]);
   }

   // 2) call a remote procedure
   session.call('f_all_profitability_updates').then(
        function (res) {
             console.log("Result:", res);
        }
   );
};

connection.open();
console.log("Opening Connection...");


Any ideas now on what might be the problem?

Thanks!


Hi Joe,

Unfortunately, with it being a weekday, I need to go to work and won't have access to look at this right now.

I'll get back to you in about 12 hours. I'll post the exact code that the website uses to make this connection then.

-Steve
Maznoz
Posts: 27
Joined: Thu Sep 03, 2015 6:02 am

Re: Write NiceHash bot, make lots of profit

Postby Maznoz » Mon Jul 25, 2016 4:43 pm

Hi,

I've been trying to connect to the wamp api using java (jawampa) and the python autobahn (asyncio) client, but both approaches result in errors. Maybe the logs are of use in diagnosing the problem:

Java:

Code: Select all

Connecting
2016-07-25 21:49:33,640 DEBUG [WampClientEventLoop io.netty.util.internal.ThreadLocalRandom:71] - -Dio.netty.initialSeedUniquifier: 0x1e953f2efabeef64 (took 0 ms)
2016-07-25 21:49:33,694 DEBUG [WampClientEventLoop io.netty.buffer.ByteBufUtil:76] - -Dio.netty.allocator.type: unpooled
2016-07-25 21:49:33,695 DEBUG [WampClientEventLoop io.netty.buffer.ByteBufUtil:76] - -Dio.netty.threadLocalDirectBufferSize: 65536
2016-07-25 21:49:33,808 DEBUG [WampClientEventLoop io.netty.util.ResourceLeakDetector:81] - -Dio.netty.leakDetectionLevel: simple
2016-07-25 21:49:33,972 DEBUG [WampClientEventLoop io.netty.util.Recycler:76] - -Dio.netty.recycler.maxCapacity.default: 262144
2016-07-25 21:49:33,978 DEBUG [WampClientEventLoop io.netty.util.internal.Cleaner0:76] - java.nio.ByteBuffer.cleaner(): available
2016-07-25 21:49:33,984 DEBUG [WampClientEventLoop io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker13:81] - WebSocket version 13 client handshake key: rsXU15kPhXpml+u4PA+KXA==, expected response: BkrcGdZprn2NaVLkKF38GZhihLs=
2016-07-25 21:49:34,094 DEBUG [WampClientEventLoop io.netty.handler.ssl.util.InsecureTrustManagerFactory:71] - Accepting a server certificate: CN=live.prohashing.com
2016-07-25 21:49:34,228 DEBUG [WampClientEventLoop io.netty.handler.ssl.SslHandler:71] - [id: 0x9d3242fe, /192.168.2.11:63756 => live.prohashing.com/98.115.147.76:443] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
2016-07-25 21:49:34,473 DEBUG [WampClientEventLoop ws.wamp.jawampa.transport.netty.WampSerializationHandler:76] - Serialized Wamp Message: [1,"mining",{"agent":"Jawampa-0.4.2","roles":{"callee":{},"caller":{"features":{"caller_identification":true}},"publisher":{"features":{"publisher_exclusion":true}},"subscriber":{"features":{"pattern_based_subscription":true}}},"authid":"web","authmethods":["wampcra"]}]
2016-07-25 21:49:34,474 DEBUG [WampClientEventLoop io.netty.handler.codec.http.websocketx.WebSocket08FrameEncoder:71] - Encoding WebSocket Frame opCode=1 length=270
2016-07-25 21:49:34,583 DEBUG [WampClientEventLoop io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder:76] - Decoding WebSocket Frame opCode=1
2016-07-25 21:49:34,583 DEBUG [WampClientEventLoop io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder:76] - Decoding WebSocket Frame length=296
2016-07-25 21:49:34,610 DEBUG [WampClientEventLoop ws.wamp.jawampa.transport.netty.WampDeserializationHandler:76] - Deserialized Wamp Message: [4,"wampcra",{"challenge":"{\"authid\": \"web\", \"authrole\": \"webviewer\", \"authmethod\": \"wampcra\", \"authprovider\": \"static\", \"session\": 1876704887325355, \"nonce\": \"FdYwHz/peKbTD/0d1Whpx1TXvHnFNUETmL6eTM2NvU5satpDvtZY8qghZyJJdzK4\", \"timestamp\": \"2016-07-25T19:49:34.523Z\"}"}]
2016-07-25 21:49:34,625 DEBUG [WampClientEventLoop ws.wamp.jawampa.transport.netty.WampSerializationHandler:76] - Serialized Wamp Message: [5,"4Fc6SHad+O4wBX8xBfKI1MK29g4lkusB+FXB7c7iuQU=",{}]
2016-07-25 21:49:34,625 DEBUG [WampClientEventLoop io.netty.handler.codec.http.websocketx.WebSocket08FrameEncoder:71] - Encoding WebSocket Frame opCode=1 length=53
2016-07-25 21:49:34,724 DEBUG [WampClientEventLoop io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder:76] - Decoding WebSocket Frame opCode=1
2016-07-25 21:49:34,725 DEBUG [WampClientEventLoop io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder:76] - Decoding WebSocket Frame length=75
2016-07-25 21:49:34,727 DEBUG [WampClientEventLoop ws.wamp.jawampa.transport.netty.WampDeserializationHandler:76] - Deserialized Wamp Message: [3,{"message":"WAMP-CRA signature is invalid"},"wamp.error.not_authorized"]


Python:

Code: Select all

WAMP-CRA challenge received: Challenge(method=wampcra, extra={'challenge': '{"authid": "web", "authrole": "webviewer", "authmethod": "wampcra", "authprovider": "static", "session": 5976856237276639, "nonce": "rLuGQ6wBghNH7F1NHE0YPB8V1EW2DkGrBjRsD3oNx8wwoDmfnop5XC+bn1bIYnkz", "timestamp": "2016-07-25T20:21:13.394Z"}'})
2016-07-25T20:21:13 wamp.error.not_authorized: WAMP-CRA signature is invalid


I've tried to connect to both:
  • wss://live.prohashing.com:443/ws
  • wss://prohashing.com:444/ws

Best,

Maznoz
User avatar
Steve Sokolowski
Posts: 2138
Joined: Wed Aug 27, 2014 3:27 pm
Location: State College, PA
Contact:

Re: Write NiceHash bot, make lots of profit

Postby Steve Sokolowski » Mon Jul 25, 2016 6:03 pm

Oops! I determined that the cause of the problem is that you should be connecting to live.prohashing.com:443, not prohashing.com:443.
JoeTheMiner
Posts: 62
Joined: Wed Nov 19, 2014 10:30 am

Re: Write NiceHash bot, make lots of profit

Postby JoeTheMiner » Mon Jul 25, 2016 6:42 pm

Steve Sokolowski wrote:Oops! I determined that the cause of the problem is that you should be connecting to live.prohashing.com:443, not prohashing.com:443.


Still doesn't seem to be working for me. It never is able to connect.

Return to “News”

Who is online

Users browsing this forum: No registered users and 1 guest