IOTA Leaderboard: Micropayments and Messaging Example
This is a fork of the IOTA Proof of Concept Application example with tutorial.
The goal is to extend the original code/repository and tutorial written by Dominik Schiener, co-funder of IOTA, because you need a local IOTA full node for the original code to work correctly.
This code utilises javascript library curl.lib.js to avoid delegation of PoW to a full node and instead the PoW is done locally. (PoW = Proof of Work, see the glossary for more info).
You can either use the final version (main branch) or try to reproduce the solution.
SECURITY WARNING
This web application needs your secret seed
, which you should never use in an online tool, unless it's approved by IOTA Foundation. Therefore I highly recommend to generate a new seed
for testing purpose only and to transfer some minimal amount of IOTA Tokens to an address generated using such a seed.
Step By Step Guide
- Clone or download the repository localy.
- Open
send.html
page in your browser. - Open the side menu by clicking on the menu icon in the top right corner.
- Click on the
MY SEED
menu item. - Paste your
secret seed
generated fortesting purpose only
. - Click
Submit
button. - Optional: Close the side menu by clicking on the
X
icon. - Fill the form
Your Name
- Name of the send, that will be displayed in the leaderboard.Value
- The amount of IOTA Tokens to be transfered. It has be less than the balance for your seed.Recipient Address
- Your address used to receive the funds. You have to use an adress which hasn't been used for sending yet. Once an address is used for sending funds, it can't never be used again.Text Area
- Some message to be sent and to be displayed in the leaderboard.
- Click on the
Submit
button. - Wait until new transaction is created, the PoW is done localy and the transfer is done. Well, it will be in the
pending
state for some time (few seconds to few minutes, depends on the net). However, you should already see that in the leaderboard. - Open
index.html
page in your browser. - Open the side menu by clicking on the menu icon in the top right corner.
- Click on the
MY SEED
menu item. - Paste your
secret seed
generated fortesting purpose only
. Ideally, use the same seed as in thestep 5
. - Click
Submit
button. - Optional: Close the side menu by clicking on the
X
icon. - Wait couple of seconds, until data for your seed is downloaded from the provider and the leaderboard is updated.
Describtion of changes
I will describe all the changes I did to the original repository. So that, you can try to reproduce that too.
- Download the original repository locally.
- 73fb676 - Formatting and semicolons - I'm using Visual Studio Code as the editor. It reformats the code on save automatically. So I've decided to fix document formatting first, to get rid of them. I also added missing semicolons in js files.
- 4d10a02 - Use a full public node as a provider - I changed the provider from the local full node to a random public full node.
- 61bfa53 - Update iota.lib.js - I had to update the iota.lib.js javascript library to the latest version, which was v0.4.7 at the moment.
- 9181046 - Use curl.lib.js for local PoW - And finally the most important step. We have to use the library curl.lib.js to avoid delegation of PoW to a full node and instead the PoW is done locally.
- Get the library - as the library project doesn't include the compiled version of the libarary, so we have to compile it:
- Clone project locally
- Run the following scripts:
npm install
npm run build
- Copy
curl.lib.js/dist/curl.min.js
toleaderboard-example/js/curl.min.js
- Include the library in send.html
- Use
curl
to overrideAttachToTangle()
function injs/send.js
, so that the PoW is done locally. - Increase the
minWeightMagnitude
from9
(used in testnet) to14
(used in mainnet).
- Get the library - as the library project doesn't include the compiled version of the libarary, so we have to compile it:
And that's it. You have a web app, that can create IOTA transactions (with value and message) while the PoW is done locally in your browser using GPU (if it's supperted by your browser). The message can afterwards be displayed in the leaderboard.