I know a user can send ETH to the contract/function manually, but is there way to request a specific amount directly in the code so that it is added to the gas fee, for example, the way dxsale.app does it when creating a presale (see screenshot below) - it adds the 0.1 ETH cost of presale to the 0.0072 gas fee for a total of 0.1072.
Can this be done in an ERC20 contract? I know I can receive ETH in a payable
function, e.g.
function deposit() payable public {
require(msg.value > 0, "You need to send some Ether");
}
but can I specify the amount I want to receive (for a flat fee), so that it is added to the tx cost?
Thank you
See Question&Answers more detail:os