A middle layer on retrieving data from the blockchain

Having had a look at the AmberDATA API documents, it seems the second approach has to be taken.

Studying AmberData 31th Dec 2019. I'll update this post as I make more notes.

Note: run the experiment queries on https://docs.amberdata.io/reference - if run on a local computer, you may get access deny error. For token level access, pro licence is needed.

Price pair: Eth / Fiat Currencies

It supports the latest price reporting of CAD, EURO, GBP, JPY, KRW, plus a hoard of stable currencies all based on USD: PAX, BUSD, HUSD, TUSD, DAI etc.

On one side, I feel this is a bit too hard-core. We may have more Polish users than we have users who need price in PAX for example. Major currency like CNY isn't in the matrix. One may question the competition (e.g. BraveNewCoin's source of various currencies including CNY) nonetheless.

Ethereum address: first occurrence in blockchain and balance

When a user sends anything to any address, he might want to see when is the address created and how much balance it holds. For example, an address that has never seen a transaction is probably a wrong address. An address which holds zero balance might have been hacked.

With amberdata you need 2 requests to get the two bits of data.

Address Token Balances

Get balance by address. Pro licence allows the server to return a list of tokens and their balances by Ethereum address. It's likely that they also return kitty lists (NFT) & this can be verified with a PRO licence.

Address Pending Transactions

To notify the user of incoming transactions, we must have something like this. This API was intended when the user flips to the wallet interface. When the user is idle (e.g. app swapped out or hasn't launched) one needs SNS which can be done by running a server to maintain a WebSocket connection and converting events to SNS notifications.

Middle layer with a fallback mechanism

There should be a middle layer by which user agents can retrieve data / subscribe to events from blockchain. The middle layer works by consulting a data aggregator and falls back to accessing blockchain nodes. There are 2 cases where the fallback happens

1. Availability

Data sources like infura, etherscan or even premium sources like AmberData can't guarantee 100% availability. Users expect the wallet to be usable as long as Ethereum is working, not as long as these specific data aggregator is working.

2. Token data is missing from some sources

TokenScript has its own way of providing Token Data, which is not going to be 100% the same as any of the data aggregator.

For example, in the case of UEFA ticket, the aggregators will need some time to recognise UEFA tickets; but AlphaWallet, thanks to the use of TokenScripts, knows these token logic as soon as it sees a token.