2

How do I send the proof of work to a node that is executed on a client?

Do I use "attachToTangle" and for branch and trunk transactions do I just use the hashed transaction with the nonce?

2
  • 1
    what client library are you using? attachToTangle will ask the node to do PoW; how to do it on client side depends on the client library (javascript, java, ...)
    – mihi
    Dec 24, 2017 at 21:01
  • 1
    and for branch and trunkyou have to ask for getTransactionsToApprove.
    – mihi
    Dec 24, 2017 at 21:02

2 Answers 2

3

You use getTransactionsToApprove to get the two transactions/tips that you need to use in your PoW. Then you must craft your transaction trytes, the Javascript libraries help with this. Then you include the two transactions, your trytes, and few other parameters as input for the cCurl program. This program can be run on the command line (C# program) or via Javascript. It will output your transaction trytes, combined with the nonce (It's all in trytes). You send these trytes to the public node/API via broadcastTransaction. And that how the client does the PoW!

Here are the links for cCurl and for javascript cCurl interface:

0

To understand how this works, you have to take a look at how transactions are generated: https://learn.iota.org/faq/what-is-needed-to-make-a-transaction

I'm assuming you use a light node.

  1. Signing: The transaction is constructed and validated using your private key. This is done locally on your PC.

  2. Tip selection: You ask a full node to give you two tips to reference and therefore validate them.

  3. Proof of work: In most cases, this is done on your side, for three reasons:

    A: Nodes are already busy handling transactions. Having to do the proof of work would probably break them and create a backlog.

    B: In most cases, Nodes are not rewarded in any way. They are keeping up the tangle for free by propagating transactions, choosing tips for light nodes and getting their neighbours up to date if they aren't.

    C: The POW is done to prevent spam attacks to the network. If a node would allow it for free, someone could just spam it.

There are a few outliers, but not many. So you just broadcast the whole transaction (with nonce) to the network (needn't be the node you received the tips from). Any node will accept the transaction, given that it is valid and not directly or indirectly validating an invalid transaction. So there is no need to send the POW, just send the whole transaction one you have completed the POW

2
  • "not referencing an unvalidated transaction" should be "not validating directly or indirectly 2 conflicting transactions" and it should be ok if the node providing tips to approve did his job honestly.
    – ben75
    Dec 26, 2017 at 18:03
  • 1
    updated my post, sounds better now Dec 26, 2017 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.