I have the following contract:
pragma solidity >= 0.5.0 < 0.7.0;
contract SimpleContract {
string public name;
address private owner;
constructor() public {
name = 'abs';
owner = msg.sender;
}
function getName() public view returns(string memory) {
return (name);
}
modifier onlyOwner(){
require(msg.sender == owner);
_;
}
function changeName(string memory _name) public onlyOwner{
name = _name;
}
}
It works if I access through the owner's account:
truffle(development)> await SimpleContract.getName()
‘abs’
But I want to access the functions through a non-owner. I am trying the following:
truffle(development)> await SimpleContract.start({from: web3.acc1}) Thrown: TypeError: SimpleContract.start is not a function at evalmachine.:1:24
truffle(development)> await web3.eth.accounts[1].SimpleContract.getName(); Thrown: TypeError: Cannot read property 'SimpleContract' of undefined at evalmachine.:1:30 reentrancy:
Somebody please guide me how to access the contract using a non-owner.
Zulfi.