I have a contract where users can buy "credits".
With that credit, users can post a message to a server (a route set up in ExpressJS).
I have the buying of credits working.
But my question is how can the code running on the server know the user actually has a credit?
I'm guessing that the user..
- signs a tx
- POSTs tx to a route on ExpressJS.
- That route calls a provider (like Infura) to check if the user has a credit.
- If they have credit, change contract state (remove one credit)
- Depending on the result, ExpressJS code allows the user to make a post or not.
Question 1 The piece that is most confusing is how the user (client-side) will sign the transaction, and NOT send it to the provider — but post the tx to Express JS/server. How is this accomplished?
Question 2 I would like to pay the gas for the user. How would I take in a client-side signed tx (necessary to prove the user is who they really are — to check their credits). But at the same time, pay the gas.
Would this mean I would need a 'signer' (with a private key available) in the server environment? How would this work?
Is this the correct way to go about it? Any pointers, articles, etc.. on this topic would be greatly appreciated!