Own Blockchain SDK for JavaScript
$ git clone https://github.com/OwnMarket/OwnBlockchainSdkJS.git
$ cd OwnBlockchainSdkJS/Source
$ npm ciRun tests:
$ npm testOwn Blockchain SDK for JS can be used in two scenarios:
own-blockchain-sdknpm packageown-blockchain-sdk.jsstandalone library
Add package to the project:
$ npm install own-blockchain-sdkUse the package in JS code:
var ownSdk = require('own-blockchain-sdk');
var networkCode = 'OWN_PUBLIC_BLOCKCHAIN_TESTNET';
// Create a new wallet
var wallet = ownSdk.crypto.generateWallet();
console.log(wallet);
// Compose a transaction with nonce = 1 and actionFee = 0.1
var tx = ownSdk.transactions.createTx(wallet.address, 1, 0.1);
tx.addTransferChxAction('CHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 100); // Transfer 100 CHX to CHxxx... address.
// Look at the raw transaction in JSON format
console.log(tx.toJson(4));
// Sign the transaction for submission to node API on TestNet
console.log(tx.sign(networkCode, wallet.privateKey));When own-blockchain-sdk.js library is referenced from the browser app,
it will create a global ownBlockchainSdk object, which contains all the SDK functionality in nested modules.
Examples of how to use the SDK can be found in the demo directory. Especially useful is the browser-demo.html file,
which shows how to generate private key and address pairs and sign transactions.
To build a standalone library for the browser, Browserify package is required:
$ sudo npm install -g browserifyBuild is started using the build.sh script (build.bat for Windows):
$ ./build.shThis results in own-blockchain-sdk.js file being created in dist directory.