IOTA Proof of Work: Remote Vs Local explained

Jan 14, 2019 · 2 min read

A proof of work is a piece of data which is difficult (costly, time-consuming) to produce but easy for others to verify and which satisfies certain requirements.

The purpose of Proof of Work is to prevent spam. IOTA ledger is secured by a heavily distributed form of CCurl Proof of Work. The IoT devices create signed transactions and compute a Proof of Work in a distributed fashion.

Without going in-depth of an IOTA transaction mechanics, we will see how a transaction is created to understand where PoW comes into play. To create a transaction:

First, we construct a transaction bundle. The bundle groups together all the individual transactions which relate to a single intent of value transfer. The constructed bundle is signed with your private keys.

Second, we randomly choose two previous unapproved transactions, or tips to approve. This will allow us to join the Tangle. We can get two tips from IRI via getTransactionsToApprove.

Third, is Proof of Work(PoW). To join Tangle every transaction in the bundle requires a nonce. The nonce is the result of PoW.

The Proof of Work can be done on the device locally or it can be delegated to external devices.

Local Proof of Work — Using CCurl WebGL2 implementation

const IOTA = require('iota.lib.js')
const curl = require('curl.lib.js')
const iota = new IOTA({ provider: 'http://localhost:14265' })curl.overrideAttachToTangle(iota.api)

Remote Proof of Work — Delegate to a 3rd party PoW service

const { composeAPI } = require('@iota/core')async function attachToTangle(
trunkTransaction, branchTransaction, mWM, trytes, cb
) {
//3rd Party PoW
const resp = await makeRequestToPoWService(...);
if ((resp[0]) != null) {
return resp[0]
} else {
return resp[1].trytes
const iota = composeAPI({
provider: 'http://localhost:14265',

If you are using IOTA.js (version ≥ 1.x.x) this library will come handy:

The library has 2 providers to choose from. ATM it supports

Image for post
Image for post

For older IOTA.js (version <1.x.x) please use the iota.lib.js.powsrvio.

Happy coding!


computer programming

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store