Questions tagged [fallback-function]

Questions dealing with the Solidity fallback function

Filter by
Sorted by
Tagged with
1
vote
2answers
27 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
0answers
20 views

Error while deploying smart contract ,BadFunctionCallOutput

The log i am having while deploying a smart contract: -------- load log data -------- user.address = 0x2154f8B602c470ae7F10f242DCC88Ae6221bb263 contract.address = ...
0
votes
2answers
44 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
532 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
16 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
54 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
40 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
43 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
27 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
60 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
49 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 ...
0
votes
1answer
205 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
2answers
76 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
147 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
211 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
45 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
64 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
70 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
150 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

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
902 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 ...
0
votes
1answer
288 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
55 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
859 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
25 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
1k 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
549 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
167 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
461 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
559 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
126 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
272 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
285 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
655 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
380 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
448 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
53 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
978 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 => ...
1
vote
2answers
1k views

Fallback function uses too much gas?

I wrote this contract but Remix complains that it uses too much gas. What am I doing wrong? "Fallback function of contract browser/SplitBalance.sol:SplitBalance requires too much gas (40612). If the ...
5
votes
1answer
8k 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 = "...
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, ...
4
votes
1answer
3k views

How to pass nested array values to the solidity function?

For Example: I am trying a sample contract where i want to pass nested array values. But i cant able to find the suitable solution ? Is it possible or do i have to change the way to send the ...
0
votes
1answer
87 views

Populus Unittesting: How to test a contract's fallback function?

How can I test the invocation of the fallback function by an external account of a contract using the Populus framework? For example, this runs forever: chain.wait.for_receipt(mycontract.transact({'...
0
votes
2answers
1k views

Can't send eth to to contract using the Remix environment

I have followed the steps of the solidity documentation to preform the work of fallback function.My code is below. pragma solidity ^0.4.0; contract Test { uint x; function () payable { }...
9
votes
3answers
919 views

Why is there more than one payable function in a solidity contract?

When someone transfers ether to a contract address the payable callback (without name) function is called automatically. What I don't understand is why are there many examples with multiple payable ...
8
votes
2answers
2k views

Anonymous function in Solidity example code

I'm following this link - https://ethereum.org/token to learn Solidity. The example contract implementation has the following line which I don't understand. Can someone please explain what is this ...
8
votes
2answers
886 views

Fallback function in web3

I find answer how to make upgradable contract here How to call function from currentVersion with fallback function on web3? contract Relay { address public currentVersion; address ...
5
votes
1answer
905 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 ...
3
votes
1answer
773 views

fallback function, best practices when registering information

I'm currently working on a smart-contract, and I have this warning in Remix : Fallback function of contract browser/token.sol requires too much gas (102480). If the fallback function requires more ...
2
votes
1answer
380 views

Fallback function doesn't get called when sending eth

With this code, at the creation of the contract (sending some eth in tx), shouldn't the fallback function be called? Then the state variable feedback shouldn't be "Fallback function correctly called"? ...