I've successfully deployed the following contract on Kaleido:
pragma solidity ^0.4.0; contract Greeter { string public greeting; function Greeter() { greeting = 'Hello'; } function setGreeting(string _greeting) public { greeting = _greeting; } function greet() constant returns (string) { return greeting; } }
I try to interact with the contract like so:
from web3 import Web3 from web3.providers import HTTPProvider from solc import compile_source from web3.contract import ConciseContract # Solidity source code contract_source_code = ''' pragma solidity ^0.4.0; contract Greeter { string public greeting; function Greeter() { greeting = 'Hello'; } function setGreeting(string _greeting) public { greeting = _greeting; } function greet() constant returns (string) { return greeting; } } ''' compiled_sol = compile_source(contract_source_code) contract_interface = compiled_sol[':Greeter'] w3 = Web3(HTTPProvider("https://user:[email protected]")) # address from previous deployment contract_address = Web3.toChecksumAddress("0x4c94e89d5ec3125339906109f143673f40868df2") greeter = w3.eth.contract( address=contract_address, abi=contract_interface['abi'], ) print('Default contract greeting: {}'.format( greeter.functions.greet().call() )) # --- this hangs --- print('Setting the greeting to Nihao...') tx_hash = greeter.functions.setGreeting('Nihao').transact({ 'from': w3.eth.accounts[0], 'gas': 100000}) w3.eth.waitForTransactionReceipt(tx_hash) print('Updated contract greeting: {}'.format( greeter.functions.greet().call() )) reader = ConciseContract(greeter) assert reader.greet() == "Nihao"
However, when I try to submit a transaction which calls setGreeting
the transaction hangs. Viewing the Kaleido logs, I see VM in read-only mode. Mutating opcode prohibited
. Also, when I visit the block explorer for my node, the transactions don't load while the blocks do.
What can I do about this read only mode?