NXTER.ORG

Create your own NXT client

By lightspeed.

Here’s an experiment for those of you with a modicum of curiosity, 3 minutes to spare and a working knowledge of wordpad, notepad or textEdit (on Mac).

Copy this 40 line code snippet and paste it into a text editor. Save the document to disk with a “html” extension (i.e. either just save it as text and manually change the extension to “.html” or save it as “my-nxt-client.html”).

<html>
<head>
<title>My NXT Client Example</title>
<script language=”Javascript”>
function xmlhttpPost(strURL) {
var xmlHttpReq = false;
var self = this;

self.xmlHttpReq = new XMLHttpRequest();
self.xmlHttpReq.open(‘POST’, strURL, true);
self.xmlHttpReq.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’);
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
updatepage(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(getquerystring());
}

function getquerystring() {
var form     = document.forms[‘f1’];
var nxtaccount = form.nxtaccount.value;

//************* Here’s the call to the NXT API: *************
//
qstr = ‘requestType=getBalance&account=’ + escape(nxtaccount);
//
//************* That wasn’t too hard was it ? *************
//
// When you’re done with that you can try this one:
//
//  qstr = ‘requestType=getAccountTransactionIds&account=’ + escape(nxtaccount)+’&timestamp=0′;

return qstr;
}

function updatepage(str){
document.getElementById(“result”).innerHTML = str;
}
</script>
</head>
<body>
<form name=”f1″>
<p>NXT Account ? <input name=”nxtaccount” type=”text”>
<input value=”Go” type=”button” onclick=’JavaScript:xmlhttpPost(“http://nxtra.org:7874/nxt”)’></p>
<div id=”result”></div>
</form>
</body>
</html>

Please note that http://nxtra.org now redirects to nxt.org. Use you own node, and also: never send your passphrase to any public node)

Open the document in a web browser (just double-click on it or, alternatively, go to the FILE menu and choose open file). If you see a form, enter a NXT account number and click the “Go” button.

If this worked for you, you’ve just created your own NXT client that uses the NXT high level API ! (Application Programming Interface) (Your balance will be out by 2 decimals but just ignore that, it’s for true geeks to worry about).

Now have a look at this page and see all the other stuff you can do just by replacing the command “getBalance” in that little NXT client you ‘wrote’. http://nxtwiki.org/wiki/The_Nxt_API#Asset_exchange_operations

Read the full article, Nxt Marked Report 020414: http://nxter.org/nxt-market-report-020414/

or here (original post on nextcoin.org forum):
https://nextcoin.org/index.php/topic,4467.msg42612.html#msg42612  (404 link removed)

Donations to lightspeed / Nxt Market Report: Nxt acc. 13411915496268579987

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

3 Comments
Oldest
Newest
Inline Feedbacks
View all comments
3
0
Would love your thoughts, please comment.x