Questions tagged [fallback-function]

Questions dealing with the Solidity fallback function

Filter by
Sorted by
Tagged with
0
votes
1answer
32 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 ...
1
vote
2answers
34 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 ...
0
votes
1answer
46 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 ...
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
2answers
48 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
32 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 ...
2
votes
2answers
60 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
1answer
32 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....
0
votes
1answer
62 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
131 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 ...
0
votes
1answer
174 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 ...
0
votes
0answers
24 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 = ...
1
vote
2answers
49 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
2answers
83 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) ...
2
votes
1answer
756 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
2answers
57 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 ...
1
vote
0answers
19 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(...
5
votes
1answer
9k 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 = "...
0
votes
1answer
50 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 ...
1
vote
1answer
31 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
73 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
59 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
223 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
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
0answers
874 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 ...
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: ...
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) ...
5
votes
1answer
932 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 ...
0
votes
1answer
675 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
1answer
155 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
228 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
47 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
67 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
73 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
156 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
987 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 ...
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 ...
0
votes
1answer
316 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
565 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: ...
2
votes
1answer
473 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
586 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 ...
2
votes
3answers
276 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
295 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 ...
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....
8
votes
2answers
914 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 ...
0
votes
2answers
394 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() ...
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 { ...
0
votes
2answers
452 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]) << ...
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 => ...
1
vote
1answer
55 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 ...