Skip to main content

Questions tagged [fallback-function]

Questions dealing with the Solidity fallback function

Filter by
Sorted by
Tagged with
0 votes
0 answers
10 views

Is there any way to explicitly trigger the fallback's execution if the msg.data matches an external function present in the contract?

I'm wondering whether there's a way to somehow explicitly trigger the fallback method, if the msg.data (calldataload, calldatasize and calldatacopy commands in Yul) already matches one of the ...
Mila A's user avatar
  • 1,254
1 vote
0 answers
19 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 ...
user127148's user avatar
0 votes
0 answers
14 views

Why fallback() function exists? [duplicate]

I am studying the fallback function, but I cannot still understand why "fallback() external payable {} " exists. It seems like it can cause security problems. why we define fallback function?...
Wonjae Choi's user avatar
1 vote
2 answers
291 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 ...
oldpride's user avatar
  • 131
0 votes
2 answers
151 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; ...
Corbin_Guo's user avatar
3 votes
2 answers
564 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 ...
CBobRobison's user avatar
  • 1,245
0 votes
1 answer
243 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 ...
Nurnberg_Meistersinger's user avatar
1 vote
1 answer
868 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 ...
RishtarCode47's user avatar
0 votes
1 answer
30 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 ^...
Simon Zhao's user avatar
0 votes
1 answer
82 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(...
Vidhan Mangla's user avatar
0 votes
1 answer
167 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 ...
shikamaru's user avatar
2 votes
1 answer
602 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 ...
Liron Achdut's user avatar
1 vote
1 answer
100 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. ...
Rjey's user avatar
  • 17
1 vote
1 answer
39 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?
tomas's user avatar
  • 41
0 votes
0 answers
51 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 ...
tomas's user avatar
  • 41
1 vote
1 answer
63 views

How to connect our smart contract that contains the fallback function to the imported smart contract?

i'm still confused, i'm importing a smart contract address on remix ethereum via ABI, i think for the fallback function it make sense to type the contract source code or use the ABI, i hope i am right ...
tomas's user avatar
  • 41
1 vote
0 answers
40 views

how import in remix smart contract without source code?

I am trying to call a fallback function on a smart contract that has not verified contract source code, How can I do this? Thanks in advance
tomas's user avatar
  • 41
1 vote
2 answers
77 views

How to send back the value sent to the fallback?

Is there a way to get and keep the value sent to the fallback/receive functions? Let's say, I want to send back Ethers that sent to my contract. Okay, existence of fallback function is enough to deal ...
Mertcan's user avatar
  • 13
0 votes
0 answers
235 views

Decode number of tokens and token contract address from msg.data (ERC-20)

I have a smart contract with just a fallback function and some logic. I want users to send their tokens directly to the smart contract to do some smart contract logic on receive. I've implemented ...
send1490's user avatar
0 votes
2 answers
3k views

address.call{}(abi.encodeWithSignature()) in solidity returns boolean and what other parameters?

I learned from this documentation https://docs.soliditylang.org/en/v0.8.15/contracts.html and this discussion How to use address.call{}() in solidity about abi.encodeWithSignature() . I have question ...
keylogger's user avatar
  • 115
0 votes
1 answer
563 views

delegate call from a fallback function using msg.data doesn't work

Please look into the following 3 contracts: // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.7; contract implementationProxy { uint public a; uint public b; address owner; ...
Rushank Savant's user avatar
0 votes
1 answer
412 views

fallback not executing

I have a test project with proxy pattern (fallback/delegate call). The purpose is to have upgradeable contracts. Here is the proxy contract: // SPDX-License-Identifier: MIT pragma solidity 0.8.13; ...
Marko's user avatar
  • 105
3 votes
2 answers
3k views

Can ERC-20 token transfers have re-entrancy?

I understand that re-entrance attack can happened when you send ETH, because of fallback() function. But in ERC20 transfer there is no call for fallback, so I wonder if there's a way to make re-...
Shaketh's user avatar
  • 31
2 votes
0 answers
214 views

how to unit test fallback function using solidity by passing data

fallback() external payable { bytes calldata data = msg.data; bytes memory lendId =bytes(data[msg.data.length-32:]); //last parameter must be lendingId uint256 _lendingId = uint256(abi....
AK4020's user avatar
  • 21
0 votes
1 answer
83 views

Events in Chained Fallback Function Cause VirtualMachineError

I’m working on an upgradeable contract that uses fallback functions with inline assembly delegatecall and call calls (using calldatacopy and returndatacopy) to route internal and external function ...
rbinnun's user avatar
  • 136
1 vote
1 answer
346 views

How to check which fallback handler is set for a Gnosis Safe

I am using a 1.3 Gnosis Safe. I want to check what fallback handler is set. I find the function that can set it: function internalSetFallbackHandler(address handler) internal { bytes32 slot = ...
mKoeppelmann's user avatar
  • 7,626
0 votes
1 answer
22 views

very important interface need help

the balance not change from another contract pragma solidity ^0.8.10; interface ICounter { function balanceOf(address owner) external view returns (uint); function transfer(address to, uint ...
aauiim's user avatar
  • 1
0 votes
1 answer
107 views

How to interact with my first defi smart contract in remix?

I found this tuto online : https://cryptomarketpool.com/create-a-defi-bank-that-pays-interest-yield-farm/ and i deployed my token and my smart contract on testnet via remix. The issue is that i am a ...
OrganicMustard's user avatar
1 vote
0 answers
58 views

What the this keyword means?

im doing the ethernaut course. what does this mean ? I know what for exemple address(this)means, it s the address of the smart contract but like what does it means when the this is alone like this?
disqid's user avatar
  • 13
0 votes
1 answer
42 views

Contract does not accept eth sent from another contract

Hi I try to send ETH from Sender contract to Receiver contract by calling sendPayment function. But I get an error. I know that the issue is the require statement in the fallback function because ...
Satoru Yamada's user avatar
0 votes
1 answer
687 views

Transferring a value into a fallback function of a contract

I'm trying to figure out what happens when you send a value to a contract. If the destination address (to) is a contract, then the EVM will execute the contract and will attempt to call the function ...
Kevvv's user avatar
  • 797
1 vote
1 answer
477 views

State variable not updated after DelegateCall

I deployed two contracts 'WalletLibrary' and 'Wallet': most of the functions in Wallet delegateCall() the functions from WalletLibrary. I want to recreate an Attack, where I call the initWallet() ...
nicollos_'s user avatar
0 votes
1 answer
64 views

Sending balance to contract fails

I'm playing ethernaut, the king of the hill level. I made a practice target contract and an attacking contract. I want to send value to the attacking contract (this works) then I want to send the ...
guernica's user avatar
0 votes
0 answers
381 views

How the fallback and receive functions in version 8 differ from fallback function in version 5 of Solidity?

I found that in version 8, we explicitly use the keyword fallback for fallback function and there is a receive function also. Consider the following code: receive() external payable { ... } fallback() ...
zak100's user avatar
  • 1,406
0 votes
0 answers
13 views

Struck with receive() and fallback() error. TypeError: "send" and "transfer" are only available for objects of type "address payable", not "address" [duplicate]

I am new to solidity, learning smart contract development. I got stuck while I was learning about the fallback function. This function throws an error saying "TypeError: "send" and &...
Karmugil's user avatar
1 vote
0 answers
141 views

Contract does not have fallback nor receive functions

In what circumstances a test can fail with the error "Contract does not have fallback nor receive functions" ? My contract already contains both a fallback and a receive function: event ...
Ward Clark's user avatar
2 votes
2 answers
2k views

web3 estimateGas() from fallback function

When I sign and send raw transactions with web3 in javascipt , to call a method from Smart Contract, I always pass the transaction gas variable after getting it with estimateGas function, from Smart ...
Alexander Herranz's user avatar
3 votes
1 answer
890 views

Why does solidity need a fallback function? [duplicate]

I understand when the fallback function is called, but why is it needed at all? It leaves the way open for a possible reentrancy attack. It is called when a function of a contract is called that isn't ...
may's user avatar
  • 31
0 votes
1 answer
268 views

Sending ether to a contract without data throws an error

I'm trying to deploy a smart contract that allows users to buy tokens that can be used to pay fees on its platform. In case someone is going to send ETH directly to the contract address without ...
C5H8NNaO4's user avatar
  • 101
1 vote
2 answers
425 views

Receive keyword in solidity

I was making a smart contract in which I wanted to send and receive ether. My code: contract coin_transfer_to { function() public payable { } function get_balance() public returns (uint) ...
user 404 not found's user avatar
0 votes
2 answers
1k views

Truffle Console: Sending Ether to a contract using fallback function

I have the following contract: pragma solidity ^0.5.8; contract Victim { address owner; constructor() public{ owner = msg.sender; } function deposit() payable public {} } If ...
zak100's user avatar
  • 1,406
0 votes
1 answer
101 views

Reflect Base contract's update in another contract

I have wanted to know what concept is it called when we want two contracts which are deployed on the Network, reflect the transaction and updates in another contract. for example: contract Base{ ...
Yash Madhwal's user avatar
2 votes
2 answers
2k views

What happens if there is no fallback function in solidity?

Here is the short definition about fallback function in solidity: Solidity fallback function does not have any arguments, has external visibility and does not return anything. What happens if there ...
user938363's user avatar
0 votes
1 answer
500 views

Way to fetch function name in fallback function with Solidity

I am writing a fallback function this way: fallback() external { (param1, param2) = abi.decode(msg.data[4:], (uint256, uint256)); } I know this is not a good practice but let's suppose i ...
Bob5421's user avatar
  • 1,477
4 votes
1 answer
789 views

Using selfdestruct in constructor

What's the purpose of such a call to this stub? contract Sacrifice { constructor(address payable _recipient) payable { selfdestruct(_recipient); } } Usage: if (_token == address(0)) { ...
Dmitry Dyachkov's user avatar
0 votes
1 answer
433 views

Why isn't my initial sendEther function not recognized as a receive ether function, am getting the error shown below [closed]

Error: This contract has a payable fallback function, but no receive ether function. Consider adding a receive ether function. Here is my code: // SPDX-License-Identifier: MIT pragma solidity >=0....
HallonDev's user avatar
0 votes
0 answers
95 views

amount of gas used in receive and fallback functions in truffle tests

I have a contract that is written in solidity ^0.6.4 and has a simple implementation of reverting funds when someone directly transfers some eth or calls an unhandled function. Now it appears to be ...
Mehrad's user avatar
  • 1
2 votes
1 answer
528 views

What is the gas limit for a fallback function called when the method does not exist?

According to the docs a non matching function identifier will trigger the fallback function. So what happens if someone calls my contract with "thisMethodDoesntExist()", would the fallback ...
Terence Chow's user avatar
1 vote
1 answer
66 views

Do gas refunds apply in a fallback function? What is the limit for non matching function identifiers?

I know that a fallback function called with a .transfer only has gas limit of 2300. What happens if the fallback function deletes some storage variables in the fallback function? Would the fallback ...
Terence Chow's user avatar
0 votes
1 answer
3k views

How should 'fallback' function be defined if we transact using 'call' method? [duplicate]

i came to know that 'call' method is better for transacting, since all gas is transferred and could withstand reentrancy attack.. but how should we define fallback function for 'call' method? using ...
vivek's user avatar
  • 3