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.24;
contract Fundraiser {
mapping(address=>uint) balances;
function withdrawCoins(){ // vulnerability inside
uint withdrawAmount = balances[msg.sender];
Wallet wallet = Wallet(msg.sender);
wallet.payout.value(withdrawAmount)();
balances[msg.sender] = 0;
}
function getBalance() constant returns (uint) {
return address(this).balance;
}
function contribute() payable {
balances[msg.sender] += msg.value;
}
function() payable {
}
}
This method is used as Adding a fund to that contract, and by this, tokens are added to that DAO, and contributing or withdrawing is enabled.
Does this mean I have to put ETH into a DAO contract to get token of that DAO contract? How can I define that (fallback)
method, and where can I get the documentation or reference for how to use it?
Thank you in advance for your answer.