Questions tagged [fallback-function]
Questions dealing with the Solidity fallback function
16
questions with no upvoted or accepted answers
3
votes
1answer
367 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 ...
1
vote
0answers
33 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(...
1
vote
1answer
6k 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
16 views
Receive keyword in solidity
I was making a smart contract in which I wanted to send and receive ether.
My code:
contract coin_transfer_to {
function() public payable {
}
function get_balance() public returns (uint)
...
0
votes
1answer
41 views
Truffle Console: Sending Ether to a contract using fallback function
I have the following contract:
pragma solidity ^0.5.8;
contract Victim {
address owner;
constructor() public{
owner = msg.sender;
}
function deposit() payable public {}
}
If ...
0
votes
1answer
54 views
Reflect Base contract's update in another contract
I have wanted to know what concept is it called when we want two contracts which are deployed on the Network, reflect the transaction and updates in another contract.
for example:
contract Base{
...
0
votes
0answers
24 views
amount of gas used in receive and fallback functions in truffle tests
I have a contract that is written in solidity ^0.6.4 and has a simple implementation of reverting funds when someone directly transfers some eth or calls an unhandled function. Now it appears to be ...
0
votes
0answers
28 views
What is the best practice to receive ether from external accounts?
I want to create a smart contract that receive ether from external accounts and pay them some profits monthly. I need to receive ether from them. What is the best practice in this regard? Whether the ...
0
votes
0answers
46 views
Failing to send() 1 wei from one contract to another
The following code is supposed to send 1 wei from the current contract to a newly created contract. The recipient contract gets created successfully and the sending contract has a positive balance, ...
0
votes
0answers
33 views
Compile error. Fallback function error
I use pragma 0.6.2. I am trying copile in truffle code which contain this lines:
fallback() external payable{}
I an getting error:
The payable fallback function is defined here.
fallback() external ...
0
votes
0answers
33 views
Truffle console: Exception instead of transaction
I am running the tutorial at:
Medium Just Dev
pragma solidity ^0.5.0;
import './Victim.sol';
contract Attacker{
Victim public v;
uint public count;
event LogFallback(uint c, uint ...
0
votes
2answers
103 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 ...
0
votes
0answers
55 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
0answers
990 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 ...
0
votes
1answer
232 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
1answer
167 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 ...