I have a contract deployed on Ethereum test network which has some functions in it and they all happen to work while using the Remix interface. When trying to call those functions using web3.py in Python, I'm able to call only for public functions and that part works fine. The problem is calling a function with a "restriction" such as having an "owner requirement", meaning only the address which created the contract can call that specific function. I've Googled it but no luck. I'm guessing that I am supposed to use both the "address" and the "password" for that Ethereum account as parameters when calling the function but I have no idea how to do it. Function is called "set()" and it takes only 2 string values.
Here is the part of Solidity code which makes the function "set()" accessible only by the owner of this contract.
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function set(string memory _lastHash,
string memory _fullHash) public onlyOwner {
lastHash = _lastHash;
fullHash = _fullHash;
}
Here is the python function which i'm using to get the return values from the other 2 functions which i've not included:
data = contract.functions.getFullHash().call()
Function is called "getFullHash()". Given Python code doesn't work with the function "set()".
contract.functions.set(arg1, arg2).transact()
. – Vanegas