0

I want to create an ERC20 token that can be used as a mode of payment for a specific contract. Out of that token will be worthless. You can imagine it as a kind of coupon. If you use that coupon for that contract only then you can get some discount otherwise not. If the same coupon is applied to a similar contract (as it accepts others as coupons) it will not work because it's a different contract. Same like real world. One coupon applies to one shop not the other.

I have searched regarding it on the internet but haven't found any relevant solution.

2 Answers 2

0

One way to do this is to code your ERC20's transfer function so that the 'from' address OR the 'to' address needs to be your smart contract's address.

That way, user to user transfers will fail, and only sending token to your smart contract or receiving tokens from your smart contract will be allowed.

2
  • I am also thinking of doing same. Thanks Commented Nov 18, 2022 at 16:33
  • Glad we agree then haha! If you could mark my answer as correct, that would be great! Commented Nov 20, 2022 at 2:36
0

Well then you should not use erc20. You do not need to use a standard. ERC20 is a standard for the reason that it is standardized and can then be supported by many applications. They just have to use the same functions.

Etherscan knows the supply of a erc20 token from : totalSupply()

Opensea knows the metadata (and can fetch metadata and pic location) from: tokenURI

And so on...

In yourcase just need to create a simple local token with mapping such as balanceOf and functions like mint and burn (...) no need to follow a standard.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.