I have this contract and can't figure out where's the problem. Any ideas? (I'm a noob in solidity, just started a few days ago).
HelloWorld.sol file:
mapping (address => uint) balances;
function HelloWorld() {
balances[msg.sender] = 1000;
}
function getBalance() public constant returns(uint) {
return balances;
}
function sendCoin(address receiver, uint amount) public constant returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
return true;
}
Moon.sol file:
mapping (address => uint) balances;
function Moon () {
balances[tx.origin] = 1000;
}
function getBalance() public constant returns(uint) {
return balances;
}
In the Moon.sol file I missed out "mapping (address => uint) balances;".
Truffle compiler error:
$ truffle compile
Compiling .\contracts\HelloWorld.sol...
Compiling .\contracts\Moon.sol...
/C/Users/guerr/SmartContracs/firstPorject/contracts/Moon.sol:10:3: :
Undeclared identifier.
balances[tx.origin] = 1000;
^------^
Compiliation failed. See above.
Moon.sol
rather thanHelloWorld.sol
, so the contents of that file (moon) are needed as well