Questions tagged [fallback-function]

Questions dealing with the Solidity fallback function

Filter by
Sorted by
Tagged with
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?
6
votes
2answers
801 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 ...
7
votes
1answer
11k views

What does Solidity's “call” function mean?

address nameReg = 0x72ba7d8e73fe8eb666ea66babc8116a41bfb10e2; nameReg.call("register", "MyName"); //1 nameReg.call(bytes4(sha3("fun(uint256)")), a); //2 if(!nameReg.call.value(10)){throw;} //3 Here ...
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 ...
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 ...
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
1answer
659 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?
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 ...
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"); ...
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'...
8
votes
1answer
967 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 ...
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 ...
9
votes
1answer
778 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 ...
17
votes
3answers
5k 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....
3
votes
2answers
748 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; ...
8
votes
2answers
940 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 ...
3
votes
1answer
2k views

How to trigger contract fallback function from Javascript

For a simple contract: pragma solidity ^0.4.11; contract Test { uint private val; function getVal() constant returns(uint) { return val; } function setVal(uint newVal) payable { ...
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
2answers
69 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
0answers
49 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#...