Hello StackExchange 👋
I'm working on my first Ethereum learning project (an ERC721 marketplace that generates tokens based on user input), wrote a couple of untested contracts and am now looking to integrate those in my app.
This is how I envision the process:
- User inputs a sentence in app
- A token is minted by the contract owner (me)
- A "Sale" contract is created for this user
- User purchases the token from the sale contract
Now, there are several things that bug me with with what I came up with:
- Because of the multi-contract approach, it seems that the transactional aspect of Ethereum is a bit broken: a token could be generated while something would fail during the sale. A malicious user could make me generate an infinite number of tokens without having the funds to pay for them.
- The JS implementations I looked at sign user transactions client-side. For my case, this would mean that I would generate the token server-side and return a payload with amount and Sale contract ID. But in that case, the user could interrupt the flow at any moment by simply reloading the page, leaving me with a bunch of unsellable tokens.
The solution I was going for:
Accepting that the full transaction happens in two times, if I can sign transaction from the user and send it to my server. Also, I coud maybe create the contract before the token then perform checks on user balance, and only at that moment mint the token.
As I said at the beginning, I'm super new to blockchain in general and take this project as an opportunity to understand things. Does the general plan makes sense? Do you have examples of such implementations in node.js, with web3.js or Infura?
Thanks a lot!