IOTA Tutorial 7 | Proof of Work, Curl and Nonce

IOTA Tutorial

Proof of Work, Curl and Nonce

In this video series different topics will be explained which will help you to understand IOTA.
It is recommended to watch each video sequentially as I may refer to certain IOTA topics explained earlier.

Making a transaction

  • Step 1. Constructing the bundle and signing the transaction inputs with your private keys.
    IOTA uses a bundle which consists of multiple transactions containing credits to the receiving addresses and debits from the spending addresses. In IOTA there are two types of transactions: one where you transfer value and thus, have to sign inputs, and ones where you simply send a transaction to an address with no value transfer (e.g. a message). A transaction is an object containing several fields such as an address, signature, value and tag.
  • Step 2. Tip selection
    The tip selection is a process whereby you traverse the tangle in a random walk to randomly chose two transactions which will be validated by your transaction. Your transaction checks for example if the descendants of that transaction is valid. If these transactions are valid they will be added to your bundle construct.
  • Step 3. Proof of Work (PoW)
    Once the bundle is constructed, signed and the tips are added to the bundle, the PoW has to be done for each transaction in the bundle. Every transaction in a bundle requires a nonce (this is the result of the PoW) in order to be accepted by the tangle network. IOTA’s PoW is directly comparable to Hashcash, as it serves a similar purpose to prevent spam, and in IOTA’s case, also to prevent sybil-attacks.ย  When the PoW is done, the nonce of the transaction object should be updated. The transaction can now be broadcasted to the tangle network and wait for it to be approved by someone else.

The IOTA light wallet uses the Curl hash algorithm for PoW. There are two methods to execute the Curl hash algorithm:

  • Method 1: Using Webgl 2 Curl implemention.
    The Curl hash algorithm is ported to Javascript (curl.lib.js) to work in WebGL-enabled browsers such as Chromium. WebGL uses the system Graphics Processing Unit (GPU).
  • Method 2: Using CCurl implementation.
    CCurl means C port of the Curl library, which uses the system Central Processing Unit (CPU) (aka native route).

PoW is executed faster using GPUs instead of CPUs. By default the IOTA light wallet uses the “Webgl 2 Curl” implementation thereby speeding up the PoW. However, some people will find that they get an “Invalid Transaction Hash” when they use this setting. In that case select the light wallet option “CCurl implementation”.

CCurl implemenation means using the C port of the Curl library for the PoW. The CCurl library can be found at: Webgl 2 Curl implementation means using the curl.lib.js ported Javascript library to work in WebGL enabled browsers for the PoW. The curl.lib.js library can be found at:ย

As mentioned earlier the purpose of the PoW is to prevent spam and sybil-attacks. PoW means calculating the nonce for every transaction in a bundle. When making a value or non value transaction you pay no fee.
However there is a small cost you are paying.ย  You pay for the electrical energy that you spend for the PoW.

The Minimum Weight Magnitude is the difficulty of PoW. An IOTA transaction data is encoded and stored in a string of 2673 trytes (= transactionObjectTrytes). The last 81 trytes of the transactionObjectTrytes is reserved for the nonce.

Execute the PoW using the transactionObjectTrytes and Minimum Weight Magnitude as input.
The PoW outputs the nonce which is 81 trytes in size.

Insert the nonce in the transactionObjectTrytes (= transactionObjectWithNonceTrytes). Convert transactionObjectWithNonceTrytes into trits (= transactionObjectWithNonceTrits) Create and initialise a CheckHash object. This object will hold the Curl hash algorithm result. Create and initialise a CurlHash object.

This object will:

  • receive inputs (absorb the transactionObjectWithNonceTrits)
  • execute the Curl hash algorithm
  • outputs the result (squeeze data into the CheckHash object)

The CheckHash object will hold the Curl hash algorithm result in trits. The number of 0โ€™s at the end of the CheckHash value must be at least the Minimum Weight Magnitude. If that is the case the nonce is valid.
A valid nonce is required for the transaction to be accepted by the tangle network.

Get real time updates directly on you device, subscribe now.

You might also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Trade IOTA with a free

$100,000 practice account

Cryptoassets are volatile instruments which can fluctuate widely in a very short time frame and, therefore, are not appropriate for all investors. Trading cryptoassets is unregulated and, therefore, is not supervised by any EU regulatory framework. 67% of retail investor accounts lose money when trading CFDs with this provider. You should consider whether you can afford to take the high risk of losing your money.