Skip to content

EddyTheCo/BuyMeACoffe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repo produce a wasm file able to monitor certain IOTA-address(Startdust). The application will show the total amount of funds (from basic outputs) on the address and also the metadata of the new transfer funds to that address. This can be used as a BuyMeACoffe app that one can embed on your website. Notice that the application do not collect the new outputs created on your address. Due to that, one needs to take care of collecting the dust on your address.

How to embed it into your webpage

  1. Include qtloader.js

  2. Include initQTwasm in your JavaScripts.

  3. Select an element of your webpage where you want the BuyMeACoffe to show and set the 'id'. like:

 <div id="qtrootDiv">
 </div>
  1. Load the wasm and emscriptem module with:
qtLoader = initQTwasm('.', 'buymeacoffe', '#qtrootDiv', 'img/qtlogo.svg');

where the first argument is the address where the buymeacoffe.wasm and buymeacoffe.js are. The second argument is the name of the application, #qtrootDiv represent the element id where you want to show it. And the last argument is the logo to show when the application is loading.

  1. Check that the module was created and once created set the node address and Startdust address(from javascript) for recieving payments like :
checkModuleLoad=setInterval(function() {
                  if (qtLoader.module())
                  {
                          qtLoader.module().Monitor.get_monitor().set_properties("https://api.testnet.shimmer.network","rms1qrzgmpr0lzvqxzu73qakkvg7v2qd2lngkaf64w256c76vepag4sqs27e25s");
                          clearInterval(checkModuleLoad);
                  }
  
                  if( typeof counter == 'undefined' ) {
                          counter = 0;
                  }
                  counter++;
                  if(counter>60)clearInterval(checkModuleLoad);
          }, 1000);

How to compile the .wasm

The only dependencies of this code are Qt.

It is necessary to have installed Qt for WebAssembly.

Clone the repo

git clone git@github.com:EddyTheCo/BuyMeACoffe.git 

Create build directory and build from there. One needs to use the qt-cmake from wasm_singlethread folder.

mkdir build 
cd build
qt-cmake  ../BuyMeACoffe/
cmake --build . 

If everything went well, the corresponding WASM file and JavaScript Api should be updated on the BuyMeACoffe/wasm source directory.

Running the web page locally

cd ../BuyMeACoffe/wasm
emrun  buymeacoffe.html