I have created a simple contract with Truffle to test things out. I am using testrpc with this.
pragma solidity ^0.4.11;
contract HelloSystem {
address owner;
function HelloSystem() {
owner = msg.sender;
}
function remove() {
if (msg.sender == owner) {
selfdestruct(owner);
}
}
}
After deploying this contract, though I can call remove
from truffle console, I am not able to call the owner which is set at the initiation of contract.
Have tried:
truffle(development)> HelloSystem.deployed().then(function(instance){HS = HelloSystem.at(instance.address)})
HS.owner.call().then(console.log)
HS.owner
HS.owner.call()
I am very well able to call remove function on my contract and remove it. But owner is not working. I am sure I am missing something simple, if any one can point it out, would be much wow many thanks.
I created another simple contract with numeric uint balance and made it public.
contract helloWorld {
uint public balance;
function helloWorld() {
balance = 1000;
}
}
Now, my call to balance works fine.
truffle(development)> helloWorld.deployed().then(function(instance){HW = helloWorld.at(instance.address)})
truffle(development)> HW.balance
{ [Function]
call: [Function],
sendTransaction: [Function],
request: [Function: bound ],
estimateGas: [Function] }
truffle(development)>
Would this be because of the declaration public/ private?
Update
Inline with my argument of public declaration, I tried declaring address public owner
still doesn't work. Hence open to your guys. Please help.