Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [fallback-function]

Questions dealing with the Solidity fallback function

0
votes
1answer
15 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
1answer
22 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
13 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
20 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
20 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
69 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 ...
0
votes
2answers
40 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
121 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
147 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
38 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
46 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
58 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
110 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
514 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
542 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
215 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?
0
votes
1answer
37 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
402 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
678 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
483 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
149 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
356 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
463 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
102 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
240 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
236 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
0answers
42 views

Using Oraclize - ETH required per query

I am new to Oraclize. I successfully implemented the test example from their web site but did notice that queries require ETH to process. https://docs.oraclize.it/#ethereum-quick-start I am looking ...
0
votes
1answer
544 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
341 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
402 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
50 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 ...
0
votes
0answers
46 views

What happens if the fallback function in Ethereum is invoked? [duplicate]

We know in Ethereum if the function signature is not found, then a specific function without any parameter, known as fallback, is invocated. What happens if fallback function in Etheruim invoked? ...
9
votes
1answer
870 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
7k 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
888 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
2k 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
85 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
873 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
771 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
860 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
736 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
318 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"? ...
0
votes
0answers
138 views

Creating the contract with ethereum in the initial tx

Why the fallback function is called, even though I send 0 ether at the start?
3
votes
2answers
643 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; ...
4
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 { ...
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 ...