MetaMask is a user-facing solution that requires authorization. It's not really suited for "batch" operations like spraying tokens on a large list of users.
For the latter, you would usually use a server with an unlocked account to iterate over the list, sign and send. The private key will be there, but it might be in a file like
.secret that is carefully guarded. It is certainly not presented to the public.
Transactions are asynchronous and the
nonce is managed by the sender. What works for a single transaction:
... doesn't work for efficient batch processes and are more like:
- sign, sign, sign, sign ...
- send, send, send, send ...
- verify, verify, verify ...
You have to manage the
nonce and know the
nonce of each transaction, especially the next because the blockchain can't reliably tell you where you are. And, if a single transaction is jammed up (gas too low?) then everything behind it will also fail to verify. That means you will have to deal with cancel and retry.
Have a look over here for a slightly more technical discussion of the options. Concurrency patterns for account nonce
Some implementations use on-chain contracts that accept an array of accounts/jobs and process them in one gulp.
Hope it helps.