1

I have the following function in my smart contract which fails to send funds to a Smart Contract Wallet (SCW). It works fine with standard accounts. I explicitly set gas to 0 because this is an internal transaction which does not consume gas.

Is there any alternative to replace .call method with a different one? How to properly send ether to SCW? I would appreciate if you could help me to fix the issue.

function sendEther (
    address to, 
    uint256 amount
  ) private {
    (bool sent, ) = payable(to).call{gas: 0, value: amount}("");
    require(sent, "Could not send ether");
  } 

1 Answer 1

0

Your problem, most likely, is that you give zero gas to the call.

The wallet receiving the funds has probably some logic to handle incoming native assets. That logic gets triggered when you try to send funds, but because it has no gas to process the logic, the whole transaction fails.

Try increasing the gas given along with the call. I'm not sure how much wallets would like to have, but maybe start with 10k?

2
  • Internal transactions do not consume gas, so that's why I explicitly set gas to 0. It won't impact the behavior of the function. This function works fine with standard accounts but if I use a Smart Contract Wallet - it fails :(
    – Kogelet
    Commented Dec 7, 2023 at 17:30
  • All contract interactions consume gas. The only time they don't use gas is if you issue a static call which doesn't alter the blockchain/contract state. But that's not related to the call you're making in your code. The code works fine with regular EOAs because they don't have any code to run when assets are sent to them. Commented Dec 7, 2023 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.