I'm looking to incorporate a ERC20 into a recently built dapp. Instead of accepting payment in the native gas token, I'd like to accept all payment in a custom ERC20.
For context, I'm not looking for a discussion on the merits of different token standards to combat the relatively poor UX of
transfer - I'm specifically talking about how a new ERC20 becomes the de facto standard of a collection of smart contracts.
Is this as simple as using the
approve pattern commonly used by LPs/farms? In the simplest example, I would imagine some call to
approve on the ERC20 itself, and then on some
Marketplace Contract or something, the
buy would call
transferFrom on the ERC20.
Is this roughly correct? Are there better ways to do this?
Additionally, there is a "services" component to the platform, meaning we have certain smart contracts where a user can pay to get some service in return. More tangibly, these are often factories - e.g. a user can pay a fee and the platform can give them a custom ERC721.
Imagine we would like to have the ability to change the price of this service over time. For example, upon launch, it costs
2 $TOKEN to use the
Factory, but at some point in the future, we would like to change that to only cost
1 $TOKEN. Any established patterns here?
I've been thinking about keeping a beacon contract (not in the way we use the term in upgradability) that contains the pricing for all the different services on that platform. This is preferred to having it be on the smart contract itself because:
- The prices for all services on the platform exist in one central + known contract, as opposed to digging through a bunch of solidity files to find where the base rate exists
- All updates go through one contract, lower security risk
- The nature of the platform uses a lot of
ProxyBeaconFactories. So, if we want to update the price, we could launch a new
implementation, and then point the beacon there, but that seems like a bad use of chain space. Additionally, we could call and
updatePriceon each proxy, but that is potentially prohibitively expensive. Hence, I consider anything related to changing state on the proxy unwieldy.
Open to any and all recommendations on the subject!