These are chat archives for ethereum/tutorials

26th
Jul 2017
Peter Mruk
@zonekidd40
Jul 26 2017 01:59
I successfully created a token, then created a crowdsale, then sent more than the required amount of tokens to that crowdsale and sent ether to that crowdsale to successfully fund the crowdsale. (in return i received those tokens back from the crowdsale contract) [All of this was created from the (basic)token and (basic)crowdsale contracts as shown on ethereum.org. ) I cannot for the life of me figure out how to claim the ether out of that crowdsale contract (its supposed to go to the beneficiary wallet account that i specified but it did not). See attached picture proving successful crowdsale contract on the ropstein test network.
image.png
I've tried messing around with the two functions inside the crowdsale contract (notably safewithdraw and check goal reached) and I'm stumped
Please help oh fair and gracious Ethereum admins and guru's
(running a full node on the ethereum wallet)
ljonathanq
@ljonathanq
Jul 26 2017 07:06

https://ethereum.org/token
Is there an updated ethereum token example? I'm using Ethereum-Wallet-macosx-0-9-0.

Error: Could not compile source code.
"throw" is deprecated in favour of "revert()", "require()" and "assert()".
if (msg.sender != owner) throw;
^---^

ENiG87
@ENiG87
Jul 26 2017 08:37
hello @ljonathanq throw is not the problem here. it will give a warning but should still work
but it seems like your if is the real problem here
what does the compiler say?
hello @zonekidd40, what is savewithdraw doing?
Peter Mruk
@zonekidd40
Jul 26 2017 11:20
safewithdraw only works if i execute the function using the beneficiary wallet and only if i send 0 ether to execute. When that goes through nothing happens. If i try to execute safewithdraw with Ether ( I was hoping that that Ether amount was the amount i wanted to withdraw, rather than send) It gives me an error saying the transaction will fail, when i send it anyway it fails, eats up my gas and still does nothing @ENiG87
ENiG87
@ENiG87
Jul 26 2017 12:26
could you give me a look at your function or did you just copy and paste from the example code?
Peter Mruk
@zonekidd40
Jul 26 2017 12:31
it was copied and pasted
but I properly filled out the correct token reward address for constructor arguments(token contract address) and beneficiary address (different than the address I created the contract with [separate wallet])
ENiG87
@ENiG87
Jul 26 2017 12:46
yeah, and i saw that you succeded in creating that token
and making that crowdsale
Peter Mruk
@zonekidd40
Jul 26 2017 12:46
Thanks to the help of you mainly
ENiG87
@ENiG87
Jul 26 2017 12:48
    function safeWithdrawal() afterDeadline {
        if (!fundingGoalReached) {
            uint amount = balanceOf[msg.sender];
            balanceOf[msg.sender] = 0;
            if (amount > 0) {
                if (msg.sender.send(amount)) {
                    FundTransfer(msg.sender, amount, false);
                } else {
                    balanceOf[msg.sender] = amount;
                }
            }
        }
so, i'm having a bit of a problem with this: why is the balance set to zero if we then want to check if its greater then zero
that doesn't work logically
also the additional two ifs don't serve any purpose in my opinion
´´´
´´
´´´
Peter Mruk
@zonekidd40
Jul 26 2017 12:51
well that whole conjecture is if fundinggoal isnt reached
we're in the else conjecture after it is reached...so balanceof[msg.sender] = amount
ENiG87
@ENiG87
Jul 26 2017 12:52
oh, my bad. good catch
Peter Mruk
@zonekidd40
Jul 26 2017 12:54
i'm not sure what writing to the contract using the safewithdrawal function does... It only allows me to send ether using the function (which fails because the crowdfund has been reached / timelimit is done), unless i'm interpreting the constructor wrong
shouldn't it have a constructor to withdraw funds?... which is what the function is supposed to be for
ENiG87
@ENiG87
Jul 26 2017 12:58
i'm still having trouble understanding the logic behind that function.
first, it checks if the fundinggoal has not been reached, so funding is still in place, so it takes the balance of the contract owner and sets it to zero, then it checks if the balance /amount is bigger then zero (which can't be the case anymore) and if that is the case, then it checks if msg.sender.send(amount) is there (i guess) and if thats the case it calls the function fundtransfer with the address of the owner, the amount and a false bool. only if the amount is zero it (again) sets the balance of to the value stored in amount (which is still zero)
please correct me if I'm wrong, but this whole function seems totally busted to me
the constructor is only needed for the contract
would be nice if some of the pros could weigh in here. did i analyze that contract wrong or is it just plain wrong?
because if you check the syntax it's clear that the else belongs to the third if check
ENiG87
@ENiG87
Jul 26 2017 13:03
ok, i was missing the second part of the function :)
yeah, in that case, if the funding goal is reached the reachedamount will be send to the beneficiary
Peter Mruk
@zonekidd40
Jul 26 2017 13:05
ok...
and it should execute automatically
but it didn't. The beneficiary wallet is at the same amount of ether and the ether is still in the crowdfunding contract
ENiG87
@ENiG87
Jul 26 2017 13:06
yeah, if it is triggered it should send it to the beneficiary
i believe you
ok, i have a hunch
you have both these functions triggered by the event afterdeadline
and it could be, that the event itself is not working properly
scratch that..
i mean, it's copy and pasted, i can'T imagine that the error is in the code, honestly
that would be devastating for the ethereum project if the sample faulty code on their website
so maybe the problem is with your client, your wallet or your connection
i'm very sorry that i can't be more of a help to you
ENiG87
@ENiG87
Jul 26 2017 13:11
Maybe somebody else could take a look, cause I'm at a loss here
Peter Mruk
@zonekidd40
Jul 26 2017 13:16
hmm... well everything else seems to be working fine. I can mine test ether just fine and do everything else just fine. Again I'm running a full node on the Ethereum wallet. They just came out with a new version yesterday (I didn't download but i can't see that as being a solution). The only thing that I've changed with the wallet/client itself was that i made a link in my CMD prompt to link the ethereum client to my D:/ harddrive rather than my C:/ solidstate because my harddrive has more space...but that shouldnt have anything to do with the solidity code executing properly.
(not the Mist wallet)
I can't imagine there being an error in the code either... I mean compared to the amount of coding it took to create the Ethereum blockchain and platform, this crowdsale code is a bicycle with two training wheels for them
is it possible that because I didnt create the shareholders association (as it is suggested in the tutorial) and that i didn't like the shareholder association as a beneficiary (rather than my wallet) that that is creating the error?
Peter Mruk
@zonekidd40
Jul 26 2017 13:21
I don't see it calling for another unknown function in another contract to execute the final funding (ehter) transfer to the beneficiary
Peter Mruk
@zonekidd40
Jul 26 2017 13:44
ALTHOUGH..... lets be honest there is an error in the crowdsale code to begin with... their first function has an extra {} whereas it should be replaced with a ;
ENiG87
@ENiG87
Jul 26 2017 14:22
yeah, i'm not sure. been doing this for 2-3 month now
but still, many more stuff zo learn
:)
Ajay Singh
@ajayatgit
Jul 26 2017 16:21
@all I have written one article on how to configure POA on ethereum using puppeth .. though it is easy but thought of writing in steps .. posting here may be helpful to some
https://www.linkedin.com/pulse/use-puppet-configure-clique-poa-private-blockchain-ajay-singh
Peter Mruk
@zonekidd40
Jul 26 2017 16:59
I think I found it....
    if (fundingGoalReached && beneficiary == msg.sender) {
        if (beneficiary.send(amountRaised)) {
            FundTransfer(beneficiary, amountRaised, false);
        } else {
            //If we fail to send the funds to beneficiary, unlock funders balance
            fundingGoalReached = false;
        }
    }
}
}
i set the beneficiary as another wallet rather than the account that created the crowdsale. I think it checked that and it came back as false
asleischow
@asleischow
Jul 26 2017 23:12
@zonekidd40 Can you post that picture again so I can see the whole thing. It cut off some of the code. Where did you set the beneficiary as another wallet? Did it work??
Nevermind, I see it all now. Still, did it work??