Site Integration

From Nxtwiki
(Redirected from Wiki/Site Integration)
Jump to: navigation, search

This guide is written to use the high-level API for Nxt, which uses JSON. Once you get a feel for the API calls, you may prefer to implement your system using the low-level Java API. Javadoc documentation for this is available in the /doc subdirectory of the Nxt software distribution.

Developers have provided some insights into good methods for implementing features in your software. This tip was created by the developers at https://www.bit777.com/ for their online casino.

Create Nxt Accounts for Site Users

In order to integrate Nxt into sites where deposits and withdrawals are used and balances must be maintained, you may have to programmatically generate Nxt account numbers automatically.

  1. Generate a random, unique password for the user
  2. Calculate the public key derived from the passphrase using the nrs.encryption.js NRS.getPublicKey() function
  3. Send this API call using the calculated public key: http://localhost:7876/nxt?requestType=getAccountId&publicKey=PUBLIC_KEY
  4. Check to see if the generated account is a collision with an existing account by issuing this API call: http://localhost:7876/nxt?requestType=getAccountPublicKey&account=GENERATED_ACCOUNT_NUMBER
  5. Store the generated password and account number securely, and associate them with the the site user's local userID.


Testing Your Implementation

For creating and testing your automated system, you can take advantage of the testnet server located at https://testnxt.jelurida.com, or run your own server, on port 6876. Once your system is up and running, you can move to your own server OR set up a new server on port 7876 to access Nxt's live network.

To get testNxt to use on the testnet, simply post your testNet address on the dedicated thread on the nxt forum or alternatively on the bitcointalk forum thread for Nxt. Developers who are constantly testing features will be able to send you some.