I want to use the Uniswap router contract to buy a token. However, I got confused by the amountoutmin(unit256) in the swapExactETHForTokensSupportingFeeOnTransferTokens of uniswap. I read the unswap documentation and it says "The minimum amount of output tokens that must be received for the transaction not to revert." Please can someone suggest what I am expected to write there and what it means. Thank you.
The Uniswap Router is a periphery contract which means that it's not strictly necessary. But still you should use it due to the fact that it protects you against various kinds of attacks on your trades.
One of the attack vectors is frontrunning your trades. That means you enter your trade, some bot notices it in the Ethereum mempool (before it's executed), creates their own trade which gets executed before your trade and their trade makes your trade less profitable for you.
To prevent this kinds of attacks the router provides various mechanisms; one of them is that
amountoutmin. You could just send X amount of Eth to Uniswap and say "give me the maximum amount of tokens for this amount of Eth I give you" but that would be suspectible to frontrunning attacks. So you also need to specify how many tokens you want at minimum with
amountoutmin. If the trading price has shifted too much between when you send the transaction and when it gets executed your trade gets reverted.
So you have to know in advance how many tokens you'd like to get, at minimum.