Interacting directly with an ERC20 token's contract for trading

I’m currently a complete beginner on Solidity with some experience on other coding languages and I’ve been checking out the tutorials on writing/deploying contracts.

I have a Uniswap-only ERC20 token and it’s not possible to sell via Uniswap because of its sell tax. Thus, I wanted to create a contract which would allow me to interact with that token’s contract directly so that I can sell that token to its contract and receive Eth in return.

Since I’m extremely new to this and there are real funds at stake, I wanted to ask for a specific guidance although there are some presets and tutorials available here.

So I apologize in advance if this had been asked here before or if it is actually easier/harder than I think it is, I would really appreciate a step-by-step roadmap; ultimately for writing a contract that would allow me to interact directly with an ERC20 token’s contract and sell that token back to its contract.

Thank you very much!

1 Like

Hi @tiger,

Welcome to the community :wave:.

I am not sure what you mean by a Uniswap-only token?

Do you want to create a Crowdsale? See https://docs.openzeppelin.com/contracts/2.x/crowdsales and Simple ERC20 Crowdsale

I recommend reading Points to consider when creating a fungible token (ERC20, ERC777). You didn’t cover what the purpose of your token was.

1 Like

Hello @abcoathup,

Actually I’m not trying to create a token. What I mean by saying a Uniswap-only token is that that token only has a liquidity pool in Uniswap. I am currently holding an ERC20 token in my eth wallet which is only tradable in Uniswap; meaning that I can’t trade it in any other DEX because there no any other liquidity pools for it.

The devs of that token put a sell-tax on the token to prevent sells (50% tax), thus I cannot sell the token via Uniswap even if I set the slippage to 49.99. I can send you the Uniswap link of the token from private but I don’t know if it’s allowed to do that here.

So what I basically want to do is; to write a contract which would allow my eth wallet to interact directly with that token’s contract address to sell that token back to its contract directly so that I can sell without using Uniswap.

It would be a really simple code as fas as I’m concerned since the only thing I want to do is to interact with its contract and sell its token back to it; in return of eth.

I hope I explained it clearly,
Thanks for your reply

1 Like

Hi @tiger,

Feel free to share the Solidity source code (e.g. a link to the source code on Etherscan or GitHub).

I am still not sure how you can transfer the token without a fee on transfer if that is what the developers have setup. Though someone in the community may be able to advise.

Hello @abcoathup,

I think I failed to define clearly what I was trying to do, nevertheless I solved it and made the transaction.

So I was basically trying to swap certain amount of an ERC20 token in return of ETH, via Uniswap. The devs implemented a selling fee which made the trade via Uniswap impossible with max. slippage. Thus, I wanted to find a way to interact with its contract address directly (bypassing Uniswap’s interface) in order to make the swap.

Here’s how I solved it:

From Etherscan, I made the transaction without using Uniswap’s interface. So there was no need for deploying a new smart contract for it.

Thank you.

1 Like

Hi @tiger,

I’m glad you were able to resolve. Thanks for sharing.

1 Like