I'm writing a contract & trying to implement a small fee for a feature when users trade NFTs & I'm getting errors everything I add a custom uint256
the transaction completely fails as such.
eth_estimateGas
Contract call: <UnrecognizedContract>
From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
To: 0xe6e340d132b5f46d1e472debcd681b2abc16e57e
Value: 0 ETH
Error: VM Exception while processing transaction: reverted with reason string 'Ether sent to address failed'
at <UnrecognizedContract>.<unknown> (0xe6e340d132b5f46d1e472debcd681b2abc16e57e)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at EthModule._estimateGasAction (/node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:429:7)
at HardhatNetworkProvider._sendWithLogging (/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:139:22)
at HardhatNetworkProvider.request (/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:116:18)
at JsonRpcHandler._handleRequest (/node_modules/hardhat/src/internal/hardhat-network/jsonrpc/handler.ts:188:20)
at JsonRpcHandler._handleSingleRequest (/node_modules/hardhat/src/internal/hardhat-network/jsonrpc/handler.ts:167:17)
Here is my function trying to send 250 wei for example to another address
function payFee(address payable _addr) external payable {
// ...... other dapp function calls
(bool success,) = _addr.call{value: 250}("");
require(success, "Ether sent to address failed");
emit PaymentSent(success);
}
Yet when I call the same function with msg.value
instead of a uint256 of 250
then the function passes. What am I doing wrong here? Is it even possible to impose a fee like this in solidity?
Value
of 250wei when sending the transaction, part of me thought it would come out automatically