I've been attempting some form of solidity code to automate the airdropping of Token B to the holders of Token A almost all day, but I still couldn't find much that works. How could I do this?
Two obvious approaches spring to mind.
An off-chain process would listen to Token A's event log to compile a list of holders and then proactively send Token B. Since Token A is constantly in motion, either a cut-off time or a continuous process and the requirement should be clarified. A notable disadvantage of this approach is the centralized gas payer bearing all the costs of transactions and infrastructure as well as the responsibility.
This has the same requirement to resolve the question of the cut-off time. I do not see an obvious way to do this on a continuous basis, but it might be possible. It's about ensuring the accounting works.
Users who are entitled to get some Token B send a transaction to a claims window contract which computes their entitlement from their Token A balance (at a point in time) and sends them their allotted Token B. This would be an on-chain solution with no transaction cost or infrastructure cost for the operator.
It should be much easier to define what the contract is supposed to do in this scenario. And, it should be trivial to ensure that transactions can complete at a known fixed gas cost that would be paid by the beneficiary who is incentivized to pay it.
A slight-of-hand method could be considered
ERC20 is about the interface and the result - not about the method.
Nothing is stopping one from computing supply and account balances using information that is available in another contract.
Your Token B balance is your Token A balance (at a cut-off time) plus or minus everything that happened here, after that.
If you wrote your ERC20 contract that way, then the airdrop would be complete at initialization.
Hope it helps.