I'd like to try to refund a call. However:
- If my contract doesn't have enough native tokens
- The sender is not payable, I don't want to fail.
I've tried it in the following way:
function performLoop() nonReentrant external {
(bool canExecute, ) = requiresExecution(false);
require(canExecute, "PEL: Nothing to Execute");
uint gasAtStart = gasleft();
uint256 gasSpent = gasAtStart - gasleft() + 28925;
try payable(msg.sender).transfer((gasSpent * tx.gasprice) + (gasSpent * (tx.gasprice/10))) { } catch { }
}
However I cannot use a try catch here since:
Try can only be used with external function calls and contract creation calls.
How can I try to send fund if they're available