Linked Questions

0 votes
1 answer

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
1 vote
1 answer

How to send ether to an 'empty' contract [duplicate]

I have two smart contracts. A caller and a receiver. My caller code looks like so: // SPDX-License-Identifier: G.P.L 3.0 pragma solidity 0.8.3; contract Caller { event Response(bool success, ...
YulePale's user avatar
  • 1,853
1 vote
1 answer

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

My contract fails to receive value (MATIC) [duplicate]

I have a problem in sending 0.01 MATIC to the smart contract, I always get the not enough funds error: the called function (createBid) is payable in the smart contract and here is the code: I tried ...
Mayyy's user avatar
  • 3
77 votes
6 answers

Fallback function in Solidity

I have seen many examples of the fallback function in Solidity, but I didn't understand any of them. Also, I've seen references to the payable modifier. My questions are: What exactly does the ...
Gopal ojha's user avatar
  • 2,249
2 votes
1 answer

How to trigger receive() fallback function | web3 geth

So Im pretty new to Solidity and I was looking into the receive and fallback functions and came across this very helpful post: What is the receive keyword in solidity? Then I read this: The receive ...
DigitalJedi's user avatar
1 vote
2 answers

Send ETH to Contract Fails in Tests

I'm trying to send ETH to a contract in tests using hardhat await owner.sendTransaction({to: greeter.address, value: "1000000"}), but it reverts with "function selector was not ...
Kof's user avatar
  • 2,954
0 votes
0 answers

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
1 vote
1 answer

Getting an error in attempting to write a withdrawAll function to remove any tokens that get sent to a contract

I am using remix: I have this function in my contract: contract Control { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); ...
Fight Fire With Fire's user avatar
0 votes
1 answer

What are the flaws of this example contract?

I am currently writing a paper/article on tokenization, in the beginning of which I introduce smart contracts. To this end, I present the following contract as an example: pragma solidity ^0.6.0; ...
typeduke's user avatar
  • 145
0 votes
0 answers

receive() keyword

How can I execute methods in receive? receive() external payable{ address _userAddress = msg.sender; uint256 _amount = msg.value; weth.deposit{value: msg.value}(); if(_amount>5){ ...
Condensator's user avatar
1 vote
1 answer

How to transfer ether within contracts?

When I use the{value: amt}(""); code, it works fine to transfer ether to EOA account but comes back false if its sent to contract. Why is that?
Hoi Nam's user avatar
  • 13