These are chat archives for ethereum/tutorials

26th
Aug 2017
brendan788
@brendan788
Aug 26 2017 06:11
Hi guys, I am a trying for the first time to create a ERC20 token
but got stuck right from the start here is the SafeMath code I am starting with

```pragma solidity ^0.4.7;

/**

  • @title SafeMath
  • @dev Math operations with safety checks that throw on error
    /
    library SafeMath {
    function mul(uint256 a, uint256 b) internal constant returns (uint256) {
    uint256 c = a
    b;
    assert(a == 0 || c / a == b);
    return c;
    }

    function div(uint256 a, uint256 b) internal constant returns (uint256) {
    // assert(b > 0); // Solidity automatically throws when dividing by 0
    uint256 c = a / b;
    // assert(a == b * c + a % b); // There is no case in which this doesn't hold
    return c;
    }

    function sub(uint256 a, uint256 b) internal constant returns (uint256) {
    assert(b <= a);
    return a - b;
    }

    function add(uint256 a, uint256 b) internal constant returns (uint256) {
    uint256 c = a + b;
    assert(c >= a);
    return c;
    }
    }

I am getting these errors

11 browser/Untitled.sol:11:5: Error: Undeclared identifier.
assert(a == 0 || c / a == b);
^----^

23 browser/Untitled.sol:23:5: Error: Undeclared identifier.
assert(b <= a);
^----^

29 browser/Untitled.sol:29:5: Error: Undeclared identifier.
assert(c >= a);
^----^

Can anyone help please
Yoichi Hirai
@pirapira
Aug 26 2017 09:09
what about require instead of assert?
manu3d
@emanuele3d
Aug 26 2017 12:52
Good day everybody! I've installed the Ethereum Wallet and I am about 150 blocks away from having downloaded the whole blockchain. No matter my (many) restarts over the past few days (I'm mostly using geth --rpc --cache=4096 to do the syncing) it appears that the closer I get to the end of the blockchain the slower it gets. Is there a reason for this?
phalexo
@phalexo
Aug 26 2017 15:29
@emanuele3d Firstly, why are you using --rpc unless you intend to connect over http://localhost:8545? Secondly, your system clock is probably not synchronized.
Parag
@pkul3003
Aug 26 2017 16:40
Hello, I need one help with running a truffle migrate project. I have created a simple smart contract and compiled using truffle compile... now when I am running truffle migrate, it is throwing an error: Error: authentication needed: password or unlock. after further check, I found that my testrpc has only 1 account and it does not have any ether balance. But the tutorial says a testrpc provides 10 accounts with some ether balance. On top of that, now when I am running testrpc, I am getting new error Error: listen EADDRINUSE :::8545
can someone please help with above issue?
manu3d
@emanuele3d
Aug 26 2017 18:20
@phalexo To be honest I have no idea why I'm using --rpc apart from the fact that it seemed quicker than not using it, as described somewhere on the internet. Regarding the clock, my Win7 system always has the "Internet Time" feature activated, but was reading from time.windows.com. I have now set it to time.nist.gov, just in case, but I had never noticed a problem with the system clock. Are we talking about fractions of seconds off the mark causing this problem?
manu3d
@emanuele3d
Aug 26 2017 18:31
Admittedly now that I have relaunched geth without --rpc I don't really see much difference in speed. But Ethereum Wallet is telling me I am about 300 blocks from the end (out of 4+ millions) and it's downloading the chain structure (again? but why?).