Fees in Bitcoin are actually a bit simpler than ethereum, you don’t have to deal with gas costs, just a fee per byte.
Bitcoin Core includes an
estimatesmartfee function. You can call it (
estimatesmartfee 2, for example) and it will give you an idea of the fee rate you need to be confirmed in n blocks (2 in my example).
You can then check your tx size, which varies by number of inputs and outputs, and just multiply it by the fee rate to get your recommended fee, and subtract that from your change output.