Hey everyone. How do I write an ERC20 contract that prevents everyone from providing liquidity on UniSwap, and only the contract itself provides it?
Jul 15, 2021, 12:18 AM
You can't. You can restrict transfer to pair contract, but that would mean user won't be able to sell as well.
Jul 15, 2021, 10:16 AM
Why not? Can’t you can check if user attached ETH with the transaction while transferring your token? Something like tx.value ?
Jul 16, 2021, 2:14 PM
There is no such thing as tx.value, only msg.value. Msg.value can only check the corresponding transactions wei amount, not the initiators. The addliquidity function is the one that takes ether and token input. Token transfer can be considered as a subtransaction created by addliquidity and this sub transaction have no access to the initiator transactions state.
For the functionality you mentioned to be implemented, you need a custom router rather than uniswaps/pcs which have this msg.value check on addliquidity function
For the functionality you mentioned to be implemented, you need a custom router rather than uniswaps/pcs which have this msg.value check on addliquidity function
Jul 16, 2021, 3:15 PM