The .transfer
functions in Solidity impose a hardcoded gas limit of 2300 gas when sending ETH to a recipient. While this is sufficient for Externally Owned Accounts (EOAs), it may not be enough for smart contracts such as multisig wallets or complex contracts with additional fallback logic. This limitation can result in failed ETH transfers and potential loss of functionality. The recommended solution is to use the .call
function, which provides flexibility by avoiding the gas limit issue and allowing developers to handle failures gracefully.
.transfer
Gas Limit Restriction:
.transfer
impose a fixed gas limit of 2300 gas for executing the recipient’s fallback or receive
function.
While this is sufficient for EOAs (simple wallets), it is often inadequate for multisig wallets or other smart contracts with additional logic in their fallback function.
Failure on Complex Contracts:
Contracts like multisig wallets typically require more than 2300 gas to perform operations like event logging or state updates in their fallback functions.
When these operations exceed the gas limit, the transfer fails, reverting the transaction.
Failed Transfers to Complex Contracts:
ETH transfers to multisig wallets or other smart contracts may fail, breaking the intended functionality.
This could result in funds being locked or inaccessible if proper error handling is not implemented.
.call
Instead of .transfer
**Replace .transfer
with .call
for ETH transfers to avoid the fixed gas limit issue.
Example Implementation:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.