I've build a smart contract and now I'm testing it using the python interface of web3.py
. In my contract, I declared some private variables and I created getter functions with modifiers to return these private variables. However, if I'm calling the getter function, the private variable is returned, no matter which account is unlocked at that moment. When testing in Remix
, the value is not returned if accessed from the same account. Does someone know if this is a web3.py
bug or has it something to do with the contract logic?
pragma solidity ^0.4.16;
contract exampleContract {
uint256 private value;
address public owner;
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function exampleContract(uint256 _value) public {
owner = msg.sender;
value = _value;
}
function viewValue() onlyOwner public returns(uint256) {
return(value);
}
}
Edit:
I think it has something to do with the Concise Contract class of web3.py
. Using the web3.py
function call()
, what is the default send address if none is provided via a transact
dictionary?
from web3 import Web3, IPCProvider
from web3.contract import ConciseContract
ipc_path = '/path/to/geth.ipc'
web3 = Web3(IPCProvider(ipc_path)
contract = web3.eth.contract(abi = abi, address = address, ContractFactoryClass = ConciseContract)
contract.viewValue() #Who is the sender when unlocking of an account is not required?