These are chat archives for ethereum/tutorials

6th
Jul 2017
Peter Mruk
@zonekidd40
Jul 06 2017 03:03
I'm trying to compile the crowdsale contract given on the ethereum.org website for my ethereum wallet running a full node on Geth, it keeps on coming up with the error "Unused local variable
contract token { function transfer(address receiver, uint amount){ } }
^--------------^
,
Unused local variable
contract token { function transfer(address receiver, uint amount){ } }
^--------------^
, **
the arrows are pointing to address receiver
Angus Fungayi Chikowore
@zimprince
Jul 06 2017 07:53
I m trying to use the ethereum wallet to create tokens and also Metamask. I want to know if i need ethereum credits in my wallet in order to create and send out these tokens and contracts
Yoichi Hirai
@pirapira
Jul 06 2017 09:01
@zimprince try replacing the {} after the arguments with a ;
@zimprince or, try removing the names of the arguments, leaving (address,uint)
ENiG87
@ENiG87
Jul 06 2017 11:07
i gues @pirapira means @zonekidd40
Yoichi Hirai
@pirapira
Jul 06 2017 11:07
Yes, I'm sorry.
ENiG87
@ENiG87
Jul 06 2017 11:09
@zonekidd40 maybe you could give us an example of the code you're running, so we now what we're dealing with. if you just copy pasted the code from the ethereum.org website it should run just fine. so you changed something and we need to know what.
ENiG87
@ENiG87
Jul 06 2017 11:15
@zimprince You always need Ether to deploy Contracts
also you need Ether to cover transaction and computation costs.
for a small contract, deployed 2-3 times, sending some test transaction to check functionality i guess you need at least 1-2 ether
be sure to use testnet ether, though, or it's gonna turn expensive real fast ;)
i recently deployed and tested a contract which handles some data and it cost me ca. 0,3 eth to deploy 3 times and send some test transaction..
Peter Mruk
@zonekidd40
Jul 06 2017 11:42
@pirapira Thank you, i will try that tonight when I get home @ENiG87 it is literally a straight copy and paste from ethereum.org; in fact I thought I may have added something in so i deleted it all and re copied and pasted from the website to no avail. I will copy and paste the ICO code when i get a chance
ENiG87
@ENiG87
Jul 06 2017 11:46
@zonekidd40 i tried it in remix and it compiles just fine. maybe it's a problem with your client.
ENiG87
@ENiG87
Jul 06 2017 12:39
@zonekidd40 could you save the contract into a file and post it here? or maybe just copy into remix and see what the compiler says..
Peter Mruk
@zonekidd40
Jul 06 2017 12:49

I copied the code into remix and a slew of errors came up. This is the copy and paste.. i created a new tab inside of the remix compiler and noticed that the header of the tab says browser/ballot.sol if that is any clue as to why it isnt compiling (never used remix before)

pragma solidity ^0.4.2;
contract token { function transfer(address receiver, uint amount){ } }

contract Crowdsale {
address public beneficiary;
uint public fundingGoal; uint public amountRaised; uint public deadline; uint public price;
token public tokenReward;
mapping(address => uint256) public balanceOf;
bool fundingGoalReached = false;
event GoalReached(address beneficiary, uint amountRaised);
event FundTransfer(address backer, uint amount, bool isContribution);
bool crowdsaleClosed = false;

/* data structure to hold information about campaign contributors */

/*  at initialization, setup the owner */
function Crowdsale(
    address ifSuccessfulSendTo,
    uint fundingGoalInEthers,
    uint durationInMinutes,
    uint etherCostOfEachToken,
    token addressOfTokenUsedAsReward
) {
    beneficiary = ifSuccessfulSendTo;
    fundingGoal = fundingGoalInEthers * 1 ether;
    deadline = now + durationInMinutes * 1 minutes;
    price = etherCostOfEachToken * 1 ether;
    tokenReward = token(addressOfTokenUsedAsReward);
}

/* The function without name is the default function that is called whenever anyone sends funds to a contract */
function () payable {
    if (crowdsaleClosed) throw;
    uint amount = msg.value;
    balanceOf[msg.sender] = amount;
    amountRaised += amount;
    tokenReward.transfer(msg.sender, amount / price);
    FundTransfer(msg.sender, amount, true);
}

modifier afterDeadline() { if (now >= deadline) _; }

/* checks if the goal or time limit has been reached and ends the campaign */
function checkGoalReached() afterDeadline {
    if (amountRaised >= fundingGoal){
        fundingGoalReached = true;
        GoalReached(beneficiary, amountRaised);
    }
    crowdsaleClosed = true;
}


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;
            }
        }
    }

    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;
        }
    }
}

}

@ENiG87
apologies, the top of the tab says browser/untitled.sol *
ENiG87
@ENiG87
Jul 06 2017 13:05
yeah, thats just your filename. you can change it by doubleclicking
ok, i copied the code in remix and it seems to work just fine.
which lines or which function doesn't work for you
?
ENiG87
@ENiG87
Jul 06 2017 13:12
ok, i created a token and tried to create the contract with the tokens adress and a testnet address and it doesn't work..
it gives the message: Error encoding arguments: SyntaxError: JSON.parse: expected ',' or ']' after array element at line 1 column 3 of the JSON data
Ilansky Naftali
@ilanoh
Jul 06 2017 13:18
Hello want to get started with eth, however some webiste states that I need alethzero mist etc, some say that the dev as stoped... Someone has a starting point ?
ENiG87
@ENiG87
Jul 06 2017 13:18
it may not be the reason: but your declaring two events but never define them..
@ilanoh try coding the three examples on the ethereum.org website
@ilanoh if you just want a quick start and don't want the hassle of maintaining a dev environment use remix
@ilanoh you can find it under remix.ethereum.org
there you can write code and test it
if you want to upload it on the real testnet ethereum chain, then you would need to use a client like ethereum wallet, also downloadable from ethereum.org
Ilansky Naftali
@ilanoh
Jul 06 2017 13:21
@ENiG87 Ok great ! 3 examples, it is organization, toker, kicktart ?
ENiG87
@ENiG87
Jul 06 2017 13:30
yes
just choose the one thats most applicable to your usecase and work from there
Ilansky Naftali
@ilanoh
Jul 06 2017 13:31
thanks
ENiG87
@ENiG87
Jul 06 2017 13:31
if you need help the fine folks here are sure to lend a hand or some eth :)
Ilansky Naftali
@ilanoh
Jul 06 2017 13:32
Thanks a lot !!
ENiG87
@ENiG87
Jul 06 2017 13:32
no problem, i was in your shoes not long ago :)
Peter Mruk
@zonekidd40
Jul 06 2017 14:22
@ENiG87 "it may not be the reason: but your declaring two events but never define them.." Well to be fair this is a copy and paste off etheruem.org, they are declaring the events and not defining them
ENiG87
@ENiG87
Jul 06 2017 14:29
ok, then the events are already defined in solidity
my bad, haven't tried myself on events, yet
but it seems it has something to do with the creation, because if you create without giving any parameters it creates just fine.
ok, i'm just stupid and forgot the set everything in quotes..
so the correct creation parameters would be
"address","X","Y","Z","address"
try it this way..
first create the token in remix, then use the address there as the address of the token
for first address you can just use any accountaddress that you have (that is, a testnet address)
Peter Mruk
@zonekidd40
Jul 06 2017 15:02
@ENiG87 Thank you. I will try this later
UriLucioWald
@UriLucioWald
Jul 06 2017 16:30
Hi all, Some smart contract newbie question . When I am sending ETH to a contract .. which function being called . How can I control it from the Contract side (assuming I deploy the contract )