Monitoring a BCH address with Tasker (Part 2: Now with more addresses!)

2 198
Avatar for elrikpiro
4 years ago

This is the second part of the Tasker BCH address monitoring tutorial since I wrote the first one several ideas came up and after implementing then I thought it would be nice to share it with you.

Link to Part 1

Improvement #1: What if I want to check more than one address?

Monitoring a single address has its uses, sure, but many of us have wallets like Bitcoin.com or Electron Cash, or both a memo.cash and a read.cash address.

Calling the REST API once per address to aggregate it's information might be tedious and demotivating... We are lucky to have REST endpoints for aggregating information from multiple addresses!

  • Before:

    • HTTP Request (Method: GET, URL: https://api.blockchair.com/bitcoin-cash/dashboards/address/{your address here}

  • After:

    • HTTP Request (Method: GET, URL: https://api.blockchair.com/bitcoin-cash/dashboards/addresses/{address1,address2,...}

JSON data from two random addresses at blockchair.com (http://jsonviewer.stack.hu/)

So as we can see at the figure on this section, Blockchair's API will return us a new data member called "set" that will give us all this information.

So we can now take the balance and balance_usd fields and have all the information we need to monitor our addresses.

Do you remember that in part 1 we used two JavaScriptlet commands to get this information? Well, today we are going to use just one.

  • Before

    • JavaScriptlet (code: var balance = JSON.parse(global('%JSON')).data.{your addres here}.address.balance;setGlobal( "%BALANCE",balance );)

    • JavaScriptlet (code:
      var usd = JSON.parse(global('%JSON')).data.{your address here}.address.balance_usd;
      setGlobal( "%BALANCE_USD", Math.round(usd*100)/100 );)

  • After

    • JavaScriptlet (code:
      var balance = JSON.parse(global('%JSON')).data.set.balance;
      setGlobal( "%BALANCE",balance );
      var usd = JSON.parse(global('%JSON')).data.set.balance_usd;
      setGlobal( "%BALANCE_USD", Math.round(usd*100)/100 );
      )

The rest of the code remains the same and everything will work fine. And that's it!

Future Work

  • Showing different BCH units at the notification when a Tx happens. (Satoshi, Bits, Ror, mBCH, BCH...)

  • Create a UI for making it easier to manage addresses

Accepting suggestions at the comment section!

Thanks for reading!

Sponsors of elrikpiro
empty
empty
empty

Link to part 3

2
$ 1.49
$ 0.56 from @hasson
$ 0.50 from @btcfork
$ 0.10 from @Telesfor
+ 1
Avatar for elrikpiro
4 years ago
Enjoyed this article?  Earn Bitcoin Cash by sharing it! Explain
...and you will also help the author collect more tips.

Comments

cool men!

$ 0.00
4 years ago

Thank you! Glad you like it ^^

$ 0.00
4 years ago