Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
retrieve last block from the NEM blockchain using the Node.js NEM-sdk
// 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));
}
});
@r9danny16

This comment has been minimized.

Copy link

@r9danny16 r9danny16 commented Jul 14, 2018

typing this code, I got the following error msg :

Invalid URI ":7890/chain/last-block"

@evias

This comment has been minimized.

Copy link
Owner Author

@evias evias commented Aug 26, 2018

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