The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [fallback-function]

Questions dealing with the Solidity fallback function

Filter by
Sorted by
Tagged with
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 ...
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 ...
9
votes
3answers
929 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 ...
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
2k 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 { }...
15
votes
1answer
2k views

How much computation can be done in a fallback function?

Simply sending Ether to a contract, will run the contract's code. In Solidity, this code maps to what it calls the fallback function. How much work can be done in a fallback function?
8
votes
2answers
3k 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 ...
3
votes
1answer
801 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
403 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"? ...
3
votes
2answers
735 views

How to make function call through relay / entry level contract

I am trying to create an entry level contract (one that is the entry point): Relay.sol pragma solidity ^0.4.8; contract Relay { address public currentVersion; address public owner; ...
7
votes
1answer
1k views

When does the fallback function get called?

Is it true to say that if the first four bytes of an Ethereum's transaction does not contain one of the contract's encoded function calls, then the fallback function will be called? In other words if ...
15
votes
1answer
2k views

Execution of Fallback function with more 2300 gas

I have tested a contract having a fallback function which updated a state variable (cost 5000 gas). I sent an amount of Ether to this contract with 100000 gas limit. The transaction is valid. As ...
12
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'...
7
votes
1answer
8k views

What's a fallback function when using address.send(…)?

This code is in my contract: contract A { address x = 0x1234...; x.send(10); } What would fallback function in the contract at address 0x1234... look like? contract B { ... } ...
5
votes
2answers
373 views

Overriding Solidity “send” function

I read that the "send" function in Solidity can be overridden. Why would someone want to do that? Is that a way to avoid execution of the fallback function at the receiver?
4
votes
2answers
221 views

Logging errors in the fallback function

In the code I return any Ether sent by mistake to contract C with the throw; statement inside the fallback function. I also want to make a log of this occasion. The following code doesn't work(throw; ...
5
votes
2answers
3k views

Understanding nameReg.call(“register”, “MyName”) style call between contracts

Here's an example from solidity docs on Address type methods(call method specifically): address nameReg = 0x72ba7d8e73fe8eb666ea66babc8116a41bfb10e2; nameReg.call("register", "MyName"); ...
4
votes
1answer
73 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 ...
4
votes
1answer
246 views

Is fallback function inheritable?

I just have no means of testing it out myself right now. contract A() { function() { throw; } } contract B is A() {}
2
votes
1answer
1k views

Unable to send ether to contract

I am working on private test-net and trying to send ether to contract but ether is not being transferred. I tried using both geth console and Mist. eth.sendTransaction({from:eth.accounts[0], to: "...
4
votes
1answer
179 views

Fallback function gets called when setting contract variables from external node

I’m a beginner in the Ethereum world and I’ve got some problems dealing with a SimpleStorage contract on my private testnet (http://solidity.readthedocs.io/en/latest/introduction-to-smart-contracts....
5
votes
1answer
655 views

Accessing the last function parameter from msg.data

I have a fallback (unnamed) function in my contract and I know that the last parameter (or first, does not matter) passed is always an uint. Is it possible to somehow access it though the msg.data?
5
votes
1answer
1k views

How do you get a string value from msg.data in the fallback function?

Im trying to do what The DAO did and do something when a sender sent money to my contract address. But im not sure how to. The something I want to do is to just create a new user in a mapping with the ...
6
votes
1answer
2k views

How does a fallback function rejecting ether work?

A contract in Solidity can have a fallback function like: // This contract rejects any Ether sent to it. It is good // practise to include such a function for every contract // in order not to loose ...
6
votes
2answers
796 views

Why does an empty message still invoke the code of the contract?

An empty message still invokes the code of the contract and is the mechanism that allows Solidity to implement a feature of a fallback function per contract. But when msg.data is empty, why does ...
9
votes
1answer
776 views

Can you call a base contract's fallback function?

Can you call the fallback function of the base contract that the current contract is inherited from? contract LittleA { function() { doLittleStuff(); // how do I call the base contract's ...
4
votes
1answer
766 views

How does a Solidity fallback function work with the raw CALL opcode of the EVM?

Since a fallback function is a Solidity feature, how does it work if the EVM opcode CALL is used? If msg.data is empty, how can Solidity run the fallback function? Shouldn't the EVM just transfer ...
8
votes
1answer
953 views

What happens if you call a non-existent function of another contract that has no fallback function in Solidity?

Let's say you call a function at another contract in Solidity: contractB.doFunction() It would then match it using the function signature to run the function in contractB. If there's not match, it ...