I am writing a contract which allows a user to deposit ether into it but when it is time to withdraw only the owner can process the withdrawals and gets to decide the amount of ether taken from your balance for your withdrawal. For some reason the withdraw function won't send any ether despite it being within the balance of the user and the contract. I am not sure why as I have been able to do this successfully in the past but not with this set up. My code is as follows:

contract sangalliCoin {

address sangalli;
mapping (address => uint) balances;

modifier sangalliOnly{ if(msg.sender != sangalli) throw; }
event _attemptWithdrawal(uint256 indexed amount, address indexed customer);

function deposit(){
  if(msg.value > 0) balances[msg.sender] += msg.value;
  else throw;

function attemptWithdrawal(uint256 amount) returns (string){
  _attemptWithdrawal(amount, msg.sender);
  return "you are probably gonna get ripped off... #sangalliCoin";

function setSangalli(){
  sangalli = msg.sender;

function withdraw(uint withdrawAmount, address user, uint256 multiple) sangalliOnly public returns (uint remainingBal) {
    if(balances[user] >= withdrawAmount * multiple) {
        balances[user] -= withdrawAmount * multiple;

        if (!user.send(withdrawAmount)) {
            balances[user] += withdrawAmount * multiple;

    return balances[msg.sender];


1 Answer 1


Not 100% sure, but the sengalliOnly modifier has no _ in it, which I would guess means that nothing happens. In other words, the code of the function 'withdraw' is non-existant. The _ in a modifier means 'insert the function code here.' Without it, I would guess the compiler simply does not insert any code. Put _ after the throw thus:

modifier sangalliOnly {
   if(msg.sender != sangalli)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.