Questions tagged [fallback-function]

Questions dealing with the Solidity fallback function

Filter by
Sorted by
Tagged with
1
vote
1answer
47 views

Why would someone have a fallback function for ^0.6.0?

A receive function allows a contract to accept eth via a send() or transfer(). As someone thought it was a good idea to have both a receive and a fallback function, I was curious what sort of scenario ...
0
votes
0answers
22 views

What is the best practice to receive ether from external accounts?

I want to create a smart contract that receive ether from external accounts and pay them some profits monthly. I need to receive ether from them. What is the best practice in this regard? Whether the ...
1
vote
1answer
4k views

gas required exceeds allowance or always failing transaction

I really need help with this error. I'm testing the contract by sending ETH to Crowdsale contract .(Ropsten, My ether wallet, Remix). Full code is here: https://ropsten.etherscan.io/address/...
0
votes
0answers
25 views

Failing to send() 1 wei from one contract to another

The following code is supposed to send 1 wei from the current contract to a newly created contract. The recipient contract gets created successfully and the sending contract has a positive balance, ...
0
votes
2answers
82 views

Fallback function calls get reverted

I created a contract which mints tokens when the msg.value is higher or equal to the token(ticket) price. Unfortunately when I send a transaction to the contract fallback it gets reverted. It's my ...
0
votes
0answers
21 views

How to call fallback function because non existing function using truffle console? [duplicate]

How I can test fallback function because non existing function in contract using truffle console?
0
votes
1answer
162 views

I want to withdraw amount from Receiver Contract's tokenFallback() function in ERC223 how to implement this scenario?

I am using ERC223 standard token transfer contract and receiver contract which includes tokenFallback(). I've transferred tokens from my ERC223 contract to receiver's contract address, now I want to ...
0
votes
0answers
20 views

Compile error. Fallback function error

I use pragma 0.6.2. I am trying copile in truffle code which contain this lines: fallback() external payable{} I an getting error: The payable fallback function is defined here. fallback() external ...
1
vote
1answer
39 views

method like fallback function for ERC20 tokens?

I want to write a contract that uses USDT (Tether) for payment. How can I use the ERC20 token as an ERC777 token, for example: Use a fallback function that executes when we receive USDT token. Or use ...
0
votes
0answers
30 views

Truffle console: Exception instead of transaction

I am running the tutorial at: Medium Just Dev pragma solidity ^0.5.0; import './Victim.sol'; contract Attacker{ Victim public v; uint public count; event LogFallback(uint c, uint ...
0
votes
1answer
145 views

Are there any security issues to send token in fallback function?

I want to have a contract that releases an erc-20 token as soon as someone pays ether to contract. Let's call this contract Bid Contract. The abstract code goes like: function askForTokens() public ...
3
votes
1answer
211 views

Contract Fallback function with ERC20

I see the fallback function of a contract as a way of "depositing" an Ether value to the contract. My question is very simple I guess, but I couldn't find the answer yet. Is it possible to develop a ...
0
votes
1answer
213 views

Can't send ether to crowdsale contract (fail) + infinite gas bug on Remix

I'm a newbie trying to make a crowdsale contract in Ropsten (deployed a token contract very well before) but i meet some problems : I can't send ether to crowdsale contract, returning a fail status ...
2
votes
1answer
761 views

What is the receive keyword in solidity?

Solidity has a receive keyword. What is it and how do I use it?
1
vote
1answer
36 views

Forward all function calls and arguments to another contract

I want to build a truly upgradable contract. I want the child contract to only implement state and then forward all functional requests to a main implementation contract. So the scheme should look ...
0
votes
2answers
128 views

Solidity 0.6.1 Receive Fallback Forwarder reverts due to insufficient gas

I am playing around with Solidity 0.6.1 and trying to build a simple funds forwarder. So ETH is sent to the contract and it sends the funds to another address. I deployed it to Ropsten. But every ...
1
vote
1answer
66 views

What's wrong with an 'empty' fallback function?

Contract A interacts with another contract B, which generally interacts with humans (ie, externally owned accounts). Thus when contract B sends ETH to contract A, contract A needs a fallback function ...
0
votes
1answer
42 views

Upgradable contract proxy pattern: Get the invoked method name in the fallback function

I have a proxy smart contract and I would like to get the name of the called method in the fallback function. Is there a way? For example, if I call the function getName() (stored in the logic ...
5
votes
1answer
81 views

Does address.send(0) make an actual call or simply return false?

Does address.send(0) makes an actual message call forwarding some small amount of gas(2300?) to fallback function or does it simply return false without making a message call to another contract? It ...
18
votes
3answers
6k views

send VS call - differences and when to use and when not to use

Can somebody please explain the differences between using a send and call for contracts and when to use and not use these different methods? For example : msg.sender.send(number); msg.sender....
13
votes
1answer
2k views

What does `call.value` mean and how did it allow the attack to The DAO?

I'm trying to get some sense from the hysteria around the attack performed to The DAO smart contract. I understand the high level explanations, but I'd like to grasp how this attack was performed. I'...
1
vote
1answer
73 views

Fallback function fails when ethers sent from metamask

This is my code snippet for fallback function, If I use it by explicity using "fallback" function on Remix, then equivalent no of tokens do come in my wallet but if I send ethers via metamask directly ...
1
vote
2answers
245 views

How to test a custom fallback function using web3.js?

I am trying to implement a proxy pattern. I have a proxy contract and a lottery contract, and I would like the proxy contract to delegate calls to the lottery contract. To test that the function ...
1
vote
1answer
54 views

How can I reduce the gas price for the fallback function?

Below is my fallback function for ethereum. It currently require 91000 gaslimit which is way more than 21000. Metamask always starts the transaction with 21000 gas stipend due to which transaction ...
2
votes
2answers
102 views

Fallback function - why revert?

Just wrote and tested the following on http://remix.ethereum.org Same happens on Ropsten network. If I run without sending any value it works, but I can't deploy the Test contract if I put any ...
0
votes
1answer
259 views

What is (fallback) method in a contract?

I'm new to Solidity programming and I don't know what is (fallback) function generated when I deploy a DAO contract. It is not defined in the contract code. Sample code I used: pragma solidity ^0.4....
1
vote
2answers
67 views

Why does fallback cause exception when expecting return value?

I want to understand, what happens under the hoods in this (very unsafe, but educative) example. contract Actual { function () external { } } interface Expected { function g() external ...
1
vote
1answer
148 views

Difference between transfer to ethereum account or to smart contract?

Is there a difference between sending ether to a user account or to a smart contract. E.g.: contract ThisIsAContract{ function() public payable {} } Now I call (pseudocode) ...
2
votes
1answer
2k views

TypeError: Fallback function must be defined as “external”

function() public payable{ ^ pragma solidity ^0.5.0; import "./EIP20Interface.sol"; contract InitialTokenOfferingIncomeFAIR is EIP20Interface { uint256 constant private MAX_UINT256 = 2**256 - ...
1
vote
2answers
86 views

Withdrawal pattern in fallback function

I need to implement withdrawal pattern for my smart contract. I wanted to make it possible to interact with contract for the people, who use smartphones and tables, just by sending some amounts of ...
1
vote
0answers
28 views

How come the gas usage of an empty fallback function is not integer?

I am trying to compute the gas usage of an empty (i.e., the most basic) fallback function. My on-chain code (compiled via Truffle 4.1.15): pragma solidity 0.4.25; contract MyContract { function(...
8
votes
1answer
11k views

Send ether to contract address in web3.js

I want to send ether to this contract's contribute function using web3.js I'm trying below code for the same but this doesn't work for me. var AbiOfContract = 'abi_code'; var contractAddress = "...
0
votes
1answer
111 views

How can I access a contract's fallback function via 'myContract.methods'?

Web3.js documentation says here that the methods of a smart contract are available through: The name: myContract.methods.myMethod The name with parameters: myContract.methods['myMethod(uint256)'] The ...
1
vote
1answer
48 views

ExecutionFailure in MultiSigWallet contract

I wanted to test a simple use case of MultiSig wallet. To do that I've deployed gnois MultiSigWallet.sol to Rinkeby network. Before testing the multisig functionality I wanted to deposit 0.1 ether to ...
1
vote
1answer
139 views

Calling nonpayable fallback from web3

Working on some smart contract security cases to become more comfortable with it but am running into an issue. In order to solve this particular puzzle, I need to initiate a fallback function from a ...
0
votes
2answers
114 views

Is payable fallback function not always invoked?

In the recommendations for smart contract security I read the following: " Remember that Ether can be forcibly sent to an account Beware of coding an invariant that strictly checks the balance of a ...
2
votes
1answer
377 views

Calling fallback function in truffle to delegate a call

I'm playing with the upgradeable contracts via DelegateProxy in Solidity. This pattern posits that a MutableForwarder contract is deployed once, and all the subsequent calls to the upgradeable ...
1
vote
1answer
1k views

how to decompile smart contract bytecode?

I don't want the whole bytecode to solidity. I just want that bytecode have fallback function and it's content. is feature in the bytecode about fallback function? about external contract call, ...
0
votes
0answers
974 views

Getting a contract's fallback payable function to fire from another contract?

My contract (contract A) is meant to send txs to another contract (Contract B). I want to end up having the fallback payable function of Contract B get called. I try to accomplish this by making a ...
2
votes
2answers
2k views

What does msg.sender.call() do in Solidity?

Hi was going through solidity documentation. There was some code that I was not able to understand, even after researching a lot I was not able to find some satisfactory output. The code is as under: ...
1
vote
1answer
31 views

Function argument quantity

Let's say we have a function such as: function tokenFallback(address sender, uint tokenAmount) And some other contract decides to call it with: contract.tokenFallback(sender, tokenAmount, data) ...
5
votes
1answer
962 views

Receiving and manipulating transaction data in smart contract

The idea is simple: you can send transactions using any ethereum wallet, and every such wallet has an additional data to send called "transaction data". For example, I want users to be able to type in ...
0
votes
1answer
758 views

Testing the fallback function with Truffle

I have the following fallback function: uint public success; function() public payable { success = 111; } I'm testing it with Truffle using this code: beforeEach(async () => { this....
0
votes
1answer
168 views

tokenReward.transferFrom does not work?

I've been struggling with how to do this for quite some time and hoping this community could help. I know that it should be added or something similar, so tokens balance of the investor address can ...
0
votes
1answer
274 views

What is the function selector of the fallback function?

The function selector are the first four bytes of the keccak256 hash of the function signature. What is the signature of the fallback function? It neither has a name nor any inputs. If there is no ...
0
votes
0answers
53 views

Why incorrect number of tokens are sent according to the current rate to the contributor.?

Token Contract https://ropsten.etherscan.io/address/0x6f5c43f62b4b18aa8ed37b42f2804f7049cbe0e9#code CrowdSale Contract https://ropsten.etherscan.io/address/0x9b94e1894abe2051e6e96bf1b57fe5d3adbbc5aa#...
0
votes
1answer
92 views

Can a smart contract be set up so that a function to forward funds sends a set percentage of the Ether received to 2 or more contracts?

For example the the openzeppelin crowdsale contract has a function that sends ether to a wallet address. Could this method include logic to send 60% of the funds received to Alice's wallet and 40% to ...
0
votes
1answer
87 views

solidity cant deposit 1.1 (float ether value)

hi this is my contract pragma solidity ^0.4.2; contract TrusteeFinTestToken { /* Public variables of the token */ string public standard = 'Token 0.1'; string public name; string ...
0
votes
1answer
192 views

Why do I need fallback function here?

I have a payable function that transfers ether to contract. function test(...) public payable returns (bool) { ... ...
0
votes
1answer
1k views

Using constructor() and the fallback function in the same contract gives error

I'm trying to compile something that mirror a pattern like this and getting the following error from remix: "browser/ballot.sol:26:3: DeclarationError: Function with same name and arguments defined ...