Get the token balance for each of the token holders by iterating through all deposit and withdrawal events from the token contract.
Reconstructing the token balances from the contract events rather than an off-chain datastore means the token balances are more likely to be accurate as off-chain datastores can get out of sync with the on-chain balances.
Using the Meetup API, get all members of the configured meetup group. For each member, try and extract an Ethereum address from the introduction field of the member's profile. The Ethereum address will be stored against the Meetup member identifier.
Using the issuer bank's transaction API, check for any new deposit transactions in the issuer's bank account since the last time this check was run.
For each new deposit into the issuer's bank account:
- Extract the Meetup member identifier from the transaction reference.
- Store the sender's bank details against the Meetup member identifier. This is used later for withdrawals.
- Look up the Ethereum address for the Meetup member's identifier.
- Validate that issuing the newly deposited tokens will not increase the token holder's balance by more than 1000 tokens.
If the previous steps fail then return the funds to the sender using the Bank payment API.
If the steps pass then issue new tokens to the token holder's Ethereum address where each dollar deposited equals the issuance of one token.
Get the list of deposit transactions into the issuer's bank account. For each deposit transaction, get the sender's bank account details so funds can be returned if they withdraw tokens or the scheme needs to be liquidated.
For each withdraw event received since the last time a withdrawal was processed, look up the token holder's bank account details used by their last deposit. Send the amount of tokens being withdrawn as dollars from the issuer's bank account to the token holder's bank account.
As the token issuer, get all the positive token holder balances. Then for each balance, redeem the balance and send a bank payment.
As the token issuser, the number of tokens on issue needs to be less than or equal to the dollars held in the bank account. This reconciliation report needs to be periodically run and exceptions raised.