read.cash Log in
@elrikpiro edited

Monitoring a BCH address with Tasker (Part 2: Now with more addresses!) 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* https://read.cash/@elrikpiro/monitoring-a-bch-address-with-tasker-a4800a09 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. https://electroncash.org/ 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! https://dev.to/asrar7787/rest-api-what-is-the-difference-between-endpoint-and-resource-3l1p 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,...}`

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. https://read.cash/@elrikpiro/monitoring-a-bch-address-with-tasker-a4800a09 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] Link to part 3 https://read.cash/@elrikpiro/monitoring-a-bch-address-with-tasker-part-3-showing-different-units-9d1eaa15

93¢

No comments yet

Log in to join in Reading is open to everyone. Replying needs an account.