elective-stereophonic
elective-stereophonic
CasinoTool : TECHNICAL AND GENERAL DISCUSSION singapore
Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Stable Nxt Client: Nxt 1.12.2

Author Topic: CasinoTool : TECHNICAL AND GENERAL DISCUSSION  (Read 1681 times)

SwissAlps

  • Hero Member
  • *****
  • Karma: +31/-16
  • Offline Offline
  • Posts: 519
    • View Profile
    • NxtTracker.com
CasinoTool : TECHNICAL AND GENERAL DISCUSSION
« on: December 27, 2014, 06:14:44 am »

Hi guys,

The CasinoTool IPO has still until Dec.31th to run, but is already a success. CasinoTool has today a capital of more than 30'000 NXT. This seems not much, especially if we compare with jl777 projects !  ;D; luckywise for the moment we do not really need a capital because the project we start with, The Lottery Project, is very simple and straightforward, and Nxt core already offers most of the needed tools.

This is more a question of organizing things, and making them work seamlessly together.

For all that are interested by this aspect of the crypto world, we hope that you will participate with your ideas, your time, your enthusiasm. And also help us test the tools.

We are now ready to start the work.
Logged
CryptoNanoPay project
Note that the "Barter Point" test has just started...

SwissAlps

  • Hero Member
  • *****
  • Karma: +31/-16
  • Offline Offline
  • Posts: 519
    • View Profile
    • NxtTracker.com
Re: CasinoTool : TECHNICAL AND GENERAL DISCUSSION
« Reply #1 on: December 29, 2014, 07:28:41 am »

Hi,

For the CasinoTool IPO, I need to establish a list of all transactions and assets. 

This is a very simple job, I know, but being quite new to HTML and JSON, is there somewhere a light open source project that does this and that I could use as a template ?

I'm just looking at the NRS source code and it is quite large.

Thanks.
less than 200 lines to do most of it: https://github.com/jl777/libjl777/blob/master/lotto.h

or if you are running SuperNET you can just issue a "lotto" SuperNET API call:

curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "SuperNET", "params": ["{\"requestType\":\"lotto\",\"refacct\":\"NXT-PY3K-SDTG-PHTV-GLYDA\",\"asset\":\"6932037131189568014\",\"lottoseed\":\"randomguess\"}"]  }' -H 'content-type: text/plain;' http://127.0.0.1:7778/

the lottoseed is the password for the prize, actually the lower 64 bits of sha256 will be used as the reference to calculate the distances.

refacct and asset are the triggers that get the set of raw txids that form each accts seed, eg. all tx that are obtaining the asset from the refacct get lotto shares. need to net out any subsequent sales so to remove the incentive to churn

James

Thanks James,

I do not want to bore the Speculation thread users with this, so I moved the discussion here...
Logged
CryptoNanoPay project
Note that the "Barter Point" test has just started...

SwissAlps

  • Hero Member
  • *****
  • Karma: +31/-16
  • Offline Offline
  • Posts: 519
    • View Profile
    • NxtTracker.com
Re: CasinoTool : TECHNICAL AND GENERAL DISCUSSION
« Reply #2 on: December 29, 2014, 07:45:39 am »

I need to explain my needs a little more :

.would like a single html file
.the html makes API calls like following :

Code: [Select]
<div class="row">
 <iframe name="frame"></iframe>
 <form method="post" target="frame"
  action="http://jnxt.org:7876/nxt?requestType=getAccountTransactionIds&account=NXT-QP3U-8ZPR-E48D-FCVW2">
   <input type="submit" />
 </form>
</div>

I retrieve then raw data

Code: [Select]
{"transactionIds":["10896103242005303380","17117479876753064460","3650487876193561991","5421583409688124557",
"11965541844315830003","5645882435623989506"],"requestProcessingTime":0}

...would want to order this data in a table...using DOM
Then call again API for more details.
All of this in a single HTML file.

Logged
CryptoNanoPay project
Note that the "Barter Point" test has just started...

jl777

  • Hero Member
  • *****
  • Karma: +718/-123
  • Offline Offline
  • Posts: 6170
    • View Profile
Re: CasinoTool : TECHNICAL AND GENERAL DISCUSSION
« Reply #3 on: December 29, 2014, 09:31:12 am »

What I did was make a lotto API:

./BitcoinDarkd SuperNET '{"requestType":"lotto","asset":"6932037131189568014","refacct":"NXT-PY3K-SDTG-PHTV-GLYDA","lottoseed":"randomguess","prizefund":"175000"}'


curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "SuperNET", "params": ["{\"requestType\":\"lotto\",\"refacct\":\"NXT-PY3K-SDTG-PHTV-GLYDA\",\"asset\":\"6932037131189568014\",\"lottoseed\":\"randomguess\",\"prizefund\":\"175000\"}"]  }' -H 'content-type: text/plain;' http://127.0.0.1:7778/

The above are two ways to invoke it. Also http://127.0.0.1:7778/{"requestType":"lotto","asset":"6932037131189568014","refacct":"NXT-PY3K-SDTG-PHTV-GLYDA","lottoseed":"randomguess","prizefund":"175000"}

this calculates both gross purchase and inbound transfers from the refacct of the asset. It also calculates the net amount, eg. someone buys and then sells, the net amount is what is creating the tickets.

the lottoseed is what determines the reference seed that determines the hamming distances

The output spits out details for each acct and a lotto summary. the dist for each ticket is in the tickets array.

array of
{
      "RS":   "NXT-AAR6-7JRL-P9AR-ED4QD",
      "seed":   "12640173392812071012",
      "buyer":   "14256227273582846692",
      "total":   "346",
      "firstblock":   307845,
      "tickets":   ["12640173392812071012", 32, "8944989347563343876", 32, "4497654647660229324", 35],
      "best":   "12640173392812071012",
      "numtickets":   3,
      "dist":   32,
      "netcount":   346
   }

the last one is a summary:

{
      "numtickets":   4577,
      "numplayers":   73,
      "netplayers":   46,
      "nettickets":   1222,
      "prizefund":   175000,
      "ave tickets":   99.50000000,
      "theoretical value":   "143.21",
      "best":   18,
      "winningticket":   "404306080033189991",
      "winners":   ["NXT-PHEY-L75X-LZRH-8X29X"],
      "prizes":   "175000.00"
   }

The code is up to 250 lines now, but it does a lot more and I think I am pretty much done with this for now

James
Logged
There are over 1000 people in SuperNET slack! http://slackinvite.supernet.org/ automatically sends you an invite

I am just a simple C programmer

jl777

  • Hero Member
  • *****
  • Karma: +718/-123
  • Offline Offline
  • Posts: 6170
    • View Profile
Re: CasinoTool : TECHNICAL AND GENERAL DISCUSSION
« Reply #4 on: December 29, 2014, 11:30:20 am »

I added a few cool features to the passthrough in the MGW bridge. So now you can play with the SuperNET API remotely just using web URL:

http://jnxt.org/init/?webcmd=SuperNET&requestType=lotto&asset=6932037131189568014&refacct=NXT-PY3K-SDTG-PHTV-GLYDA&lottoseed=randomguess&prizefund=175000

The above runs the lotto calcs and returns JSON

James
Logged
There are over 1000 people in SuperNET slack! http://slackinvite.supernet.org/ automatically sends you an invite

I am just a simple C programmer

SwissAlps

  • Hero Member
  • *****
  • Karma: +31/-16
  • Offline Offline
  • Posts: 519
    • View Profile
    • NxtTracker.com

Hi James, thanks for your info.

But for the moment, my problem is more simple, and being new to HTML and JSON and DOM, I just need small guidelines about the best way to achieve this simple task. A lot of forum members are quite helpful, and may be someone that has already done this can just give me a small info in a few lines, it doesnt need to be the running version.

I use the following :

Code: [Select]
<div class="row">
 <iframe name="frame"></iframe>
 <form method="post" target="frame"
  action="http://jnxt.org:7876/nxt?requestType=getAccountTransactionIds&account=NXT-QP3U-8ZPR-E48D-FCVW2">
   <input type="submit" />
 </form>
</div>

And I get following raw data

Code: [Select]
{"transactionIds":["10896103242005303380","17117479876753064460","3650487876193561991","5421583409688124557",
"11965541844315830003","5645882435623989506"],"requestProcessingTime":0}

This is ok and works for me.

What I would like to do is treat this data and present it in a table like following :

10896103242005303380
17117479876753064460
3650487876193561991
5421583409688124557
11965541844315830003
5645882435623989506

See, not a difficult task, or so it seems. Should I use the Event handler ?

I would really appreciate some HTML advice from more seasoned users....thanks
Logged
CryptoNanoPay project
Note that the "Barter Point" test has just started...

Riker

  • Core Dev
  • Hero Member
  • *****
  • Karma: +440/-42
  • Offline Offline
  • Posts: 1796
    • View Profile
Re: CasinoTool : TECHNICAL AND GENERAL DISCUSSION
« Reply #6 on: December 30, 2014, 06:16:53 am »

The data returned from the server is in JavaScript Object Notation format a.k.a JSON.
To lay it out in an Html table format you'll need to use JavaScript. In the NXT core we are using the JQuery and Bootstrap JavaScript libraries for this purpose.
If you don't have any other dependency, I suggest you simply Google "json to html table" and follow the links to learn how this can be accomplished. Another approach would be to look at the code provided by NXT itself, under the /html/nrs folder and reuse some of the code and techniques.
Logged
NXT Core Dev
Account: NXT-HBFW-X8TE-WXPW-DZFAG
Public Key: D8311651 Key fingerprint: 0560 443B 035C EE08 0EC0  D2DD 275E 94A7 D831 1651

SwissAlps

  • Hero Member
  • *****
  • Karma: +31/-16
  • Offline Offline
  • Posts: 519
    • View Profile
    • NxtTracker.com
Re: CasinoTool : TECHNICAL AND GENERAL DISCUSSION
« Reply #7 on: December 30, 2014, 07:11:03 am »

The data returned from the server is in JavaScript Object Notation format a.k.a JSON.
To lay it out in an Html table format you'll need to use JavaScript. In the NXT core we are using the JQuery and Bootstrap JavaScript libraries for this purpose.
If you don't have any other dependency, I suggest you simply Google "json to html table" and follow the links to learn how this can be accomplished. Another approach would be to look at the code provided by NXT itself, under the /html/nrs folder and reuse some of the code and techniques.

Thanks very much, that's exactly what I needed, global and general indications.
Have a nice day.
Logged
CryptoNanoPay project
Note that the "Barter Point" test has just started...
 

elective-stereophonic
elective-stereophonic
assembly
assembly