Questions tagged [fallback-function]

Questions dealing with the Solidity fallback function

Filter by
Sorted by
Tagged with
0
votes
0answers
19 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
26 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 ...
1
vote
1answer
550 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
30 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
111 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
55 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
39 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 ...
1
vote
2answers
204 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 ...
3
votes
1answer
178 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 ...
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 ...
1
vote
1answer
67 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 ...
0
votes
1answer
231 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....
2
votes
2answers
94 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 ...
1
vote
2answers
66 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 ...
2
votes
1answer
1k 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
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(...
0
votes
1answer
143 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
1answer
109 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 ...
0
votes
2answers
75 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 ...
1
vote
1answer
47 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
129 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
111 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
362 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
146 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) ...
0
votes
1answer
167 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
273 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
52 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
85 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
190 views

Why do I need fallback function here?

I have a payable function that transfers ether to contract. function test(...) public payable returns (bool) { ... ...
1
vote
1answer
3k 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
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 ...
1
vote
1answer
376 views

How to write a function that is automatically called when a contract receives an ERC20 token?

Fallback functions only work when a contract receives ether. Is there a way to write a fallback-style function that is automatically called when a contract receives an ERC20 token?
1
vote
2answers
81 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 ...
0
votes
0answers
972 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 ...
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) ...
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: ...
0
votes
1answer
617 views

send ether from one contract to another automatically

I want to transfer ether from Child Contract to Parent Contract automatically whenever someone send ether to child. In fallback function i tried to run the function and it is giving error: VM error: ...
0
votes
1answer
211 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
526 views

Truffle send to fallback function from different account

I'm testing a simple fallback function with Truffle, the fallback function is: function () public payable { internalTransfer(this, msg.sender, 100000000); FundSuccess(msg.sender, msg.value); }...
2
votes
1answer
723 views

fallback function is accepting more than 2300 gas

Quoting from solidity doc: In such a context, there is usually very little gas available to the function call (to be precise, 2300 gas), so it is important to make fallback functions as cheap ...
0
votes
1answer
142 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 ...
2
votes
3answers
289 views

why don't popular tokens have payable fallback

I'm referring to the source of of the most popular tokens on etherscan. It looks like they don't have any payable functions. How do they accept ether and transfer the tokens automatically when ...
2
votes
1answer
337 views

address.transfer no transaction on etherscan

I tested fallback function in my smart contract, and noticed, that there is no transaction on etherscan from smart contract to my account. In short: i try to send money to contract and receive back a ...
0
votes
1answer
744 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
2answers
433 views

How to call undefined method of a contract using truffle javascript?

I have a dispatching contract, that defines fallback function to send all "undefined" calls to implementation contract using delegatecall: contract Dispatcher{ address _implementation; function() ...
0
votes
2answers
485 views

How to make function signature? ERC223 ContractReceiver

Hi what does these lines mean? function tokenFallback(address _from, uint _value, bytes _data) { ... uint32 u = uint32(_data[3]) + (uint32(_data[2]) << 8) + (uint32(_data[1]) << ...
1
vote
1answer
58 views

Differences between nameFunction.value and address.transfer

What is the difference between using nameFunction.value(n)(parameters of nameFunction) and address.transfer(10)? I know that in the case of address.transfer, I'll send the amount to the fallback ...
9
votes
1answer
1k views

Send ether reentrancy attack in reality - how could fallback function make a message call back into current contract?

Below is quoted from solidity docs: pragma solidity ^0.4.0; // THIS CONTRACT CONTAINS A BUG - DO NOT USE contract Fund { /// Mapping of ether shares of the contract. mapping(address => ...