Corrections and additions to Geth Frontier examples

anthonyc0603anthonyc0603 Member Posts: 1
edited August 2015 in Education
As a first time user, I came across the following which could be improved in the Frontier examples when using geth;

If you spread your learning over more than one session and log out and then log in again, you need to execute person.unlockAccount('passprhase') before you execute the code to deploy your contract. Might be worth mentioning this in the tutorial as it took be a few scratches of my head to figure out why the deployment was failing.

Second, the solidity script for creating a coin does not compile. the problem is 'coinBalanceOf[msg.sender] = (supply || 10000);'

contract token {
mapping (address => uint) public coinBalanceOf;
event CoinTransfer(address sender, address receiver, uint amount);

/* Initializes contract with initial supply tokens to the creator of the contract */
function token(uint supply) {
coinBalanceOf[msg.sender] = (supply || 10000);
}

/* Very simple trade function */
function sendCoin(address receiver, uint amount) returns(bool sufficient) {
if (coinBalanceOf[msg.sender] < amount) return false;
coinBalanceOf[msg.sender] -= amount;
coinBalanceOf[receiver] += amount;
CoinTransfer(msg.sender, receiver, amount);
return true;
}
}

The error on the online compiler reads

Type error: Operator || not compatible with types uint256 and int_const 10000
coinBalanceOf[msg.sender] = (supply || 10000);
^-------------^

Not sure what the problem is but it can be worked around by just removing the 'supply ||' so the amount issued is a constant 10000

Otherwise, great job and I am looking forward to playing some more.
Post edited by anthonyc0603 on

Comments

Sign In or Register to comment.