Last active
August 26, 2018 11:22
-
-
Save evias/effd71fbb3e357d7da5f26fd2b4f9d58 to your computer and use it in GitHub Desktop.
retrieve last block from the NEM blockchain using the Node.js NEM-sdk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// include the NEM-sdk package in your package.json first. | |
// nem-sdk: npmjs.com/package/nem-sdk | |
let nem_ = require("nem-sdk").default; | |
let connectedNode = nem_.model.objects.create("endpoint")("http://bigalice2.nem.ninja", "7890"); | |
nem_.com.requests.chain.lastBlock(connectedNode) | |
.then(function(err, block) | |
{ | |
if (! err && block) { | |
console.log("NEM Testnet blockchain last block: " + JSON.stringify(block)); | |
} | |
}); |
This means that you probably modified the URL set in connectNode. It works fine for me after running it in a javascript console with nem-sdk available.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
typing this code, I got the following error msg :
Invalid URI ":7890/chain/last-block"