Questions tagged [fallback-function]
Questions dealing with the Solidity fallback function
140 questions
1 vote
1 answer
38 views
Mappings with function type
I was trying to test something, and found that we can have function type inside a mapping like this: contract Test { uint public number; // Internal function to set the number function ...
1 vote
1 answer
44 views
Is it possible for a contract to completely prevent incoming ETH transfers?
Can a contract be designed in such a way that it will always have a balance of zero ETH? Maybe this can be achieved by skipping the payable modifier in all functions, and not implementing the fallback ...
1 vote
0 answers
36 views
Why doesn't this solution for ethernaut work?
I am working on the ethernaut CTF level (code below)...I need to take over ownership of the instance (it's been deployed). I thought I could do it by sending a small amount of ETH to the instance ...
1 vote
2 answers
359 views
Solidity low-level call and fallback function failed in hardhat-deploy
I am using examples in soliditylang.org special functions My simple contracts are extracted from the link // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.2 <0.9.0; contract ...
0 votes
2 answers
204 views
Get an error calling delegate contract function with hardhat console
Here is my code contract SimpleUpgrade { address public implementation; address public admin; string public words; constructor(address _implementation) { admin = msg.sender; ...
3 votes
2 answers
762 views
What happens when a validator's withdrawal address is a smart contract with a fallback function?
Ethereum validators set a withdrawal address to automatically receive their staking rewards. These rewards are distributed gas free at the protocol level through a process called "validator ...
0 votes
1 answer
279 views
Disadvantages of using `call` function
Hey guys, I was reading about low-level methods of calling other contract functions and I found the following description of call method: This is the recommended method to use when you're just ...
1 vote
1 answer
1k views
Fallback and Receive functions in Solidity [duplicate]
I have a contract that needs to be able to receive Ether. The contract includes a receive function to receive Ether but I wonder if it's good practice to also have a fallback function in case someone ...
0 votes
1 answer
44 views
questions about Re-Entrancy attack syntax
hey guys I come across this video about re-entrancy attack posted by Chainlink, but I have some questions about the syntax being covered. please help. // SPDX-License-Identifier: MIT pragma solidity ^...
0 votes
1 answer
96 views
I can't compile my contract. What's wrong with this fallback function?
function () payable external { address impl = methodsImplementations[msg.sig]; require(impl != address(0x00), "Method not found. 404"); assembly { let p := mload(...
0 votes
1 answer
196 views
Unable to deposit ether inside contract using receive function
Code is : contract sendEther{ //to send ether, we need to deposit some ether first in this contract //We can do it by declaring constructor as payable which enables us to deposit some ether ...
2 votes
1 answer
717 views
The low-level functions call, delegatecall and staticcall return true as their first return value if the account called is non-existent
According to the official Solidity documentation: The low-level functions call, delegatecall and staticcall return true as their first return value if the account called is non-existent, as part of ...
1 vote
1 answer
137 views
Guess the number game , not working
I am trying to write a game on smart contract which is a game in which the player has to type in 5 guesses, and based on how close they were to the actual number, they would receive ether as prize. ...
1 vote
1 answer
48 views
decompiler smart contract code, how to read the result?
i scanned the smart contract in the decompiler, how will the withdrawal function be translated?
0 votes
0 answers
59 views
The old owner and the new owner of the smart contract
I encountered such a problem, when i imported the smart contract unto remix, i did this through ABI...ok one wallet created two contracts, different times, the first contract is now worthless. i'm ...