SDK Introduction
1.1 - Installation
For the browser:
Download the library source, open the dist/ folder and put nem-sdk.js into your project.
Library include the require() function so you can require() the module directly
<script src="nem-sdk.js"></script>
<script>
// Include the library
var nem = require("nem-sdk").default;
console.log(nem)
</script>
For Node:
Using npm:
npm install nem-sdk
// Use require
var nem = require("nem-sdk").default;
// ES6
import nem from 'nem-sdk';
Using build/ folder:
// Use the build/ folder
var nem = require("path/to/build/index.js").default;
1.2 - Build
Install dependencies:
npm install
Build:
npm run build
Build for the browser (after above build):
npm run browserify
1.3 - Organisation
The SDK is organised in namespaces and sub-namespaces.
There is 4 main namespaces:
nem.com
requests: Requests to NIS and the outside worldwebsockets: Connection, subscription and requests to NIS websockets
nem.crypto
keyPair: Functions to create keypair from hex and sign data with ithelpers: Miscellaneous cryptographic functions, like encrypt private key, decrypt a wallet, derive a password…nacl: External cryptographic library modified for NEMjs: Access to the crypto-js library
nem.model
address: Functions regarding NEM addresses like base32 encoding / decoding, verify, convert public key to address…objects: Contains usesul objects modelsfees: Contains all the transaction fees and calculation functionsnetwork: Contains networks types and functions relatednodes: Contains array of nodes for different networks, default nodes, search by hash nodes…sinks: Contains the sink addresses for namespaces and mosaics by networktransactions: Contains functions to prepare and send transaction objectstransactionTypes: Contains all the NEM transactions typeswallet: Contains functions to create wallets
nem.utils
convert: Contains convertion functionshelpers: Contains miscellaneous helper functionsformat: Contains miscellaneous formatting functionsnty: Contains functions to build nty dataSerialization: Contains functions to serialize transactions
Consult the code directly for details, almost all functions are commented, with parameters, return values and types.