I've successfully deployed my contract to Kaleido but I'm having trouble figuring out how to correctly verify it. Here is the source code deploys the contract and I've verified the the address printed by the last print statement appears in my Kaleido blockchain:
from web3 import Web3 from web3.providers import HTTPProvider from solc import compile_source # 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) # Compiled source code contract_interface = compiled_sol[':Greeter'] w3 = Web3(HTTPProvider("https://XXXXX:[email protected]")) contract_ = w3.eth.contract( abi=contract_interface['abi'], bytecode=contract_interface['bin']) # note: when interacting with kaleido, gasPrice MUST be 0 (I think because of the consensus algorithm I chose) # and it seems it doesn't matter what account this is sent from construct_txn = contract_.constructor().buildTransaction({ 'from': w3.eth.accounts[0], 'gas': 1728712, 'gasPrice': 0}) txn = w3.eth.sendTransaction(construct_txn) tx_receipt = w3.eth.getTransactionReceipt(txn) contract_address = tx_receipt['contractAddress'] print(contract_address)
When I try to verify my contract, I'm asked to provide the source code, the contract name, a compiler version and whether optimization was used.
I use the following for the requested 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; } }
I use Greeter
as the contract name. solc --version
returns Version: 0.4.24+commit.e67f0147.Darwin.appleclang
which I found was committed on May 16: https://github.com/ethereum/solidity/search?q=e67f0147&type=Commits.
I've tried all of the following combinations for compiler version + optimization enabled: {0.4.24, 0.4.24-nightly.2018.5.16} x {optimization enabled, optimization disabled} and none of these combinations worked. I get the following error when I try 0.4.24-nightly.2018.5.16 as the compiler and optimization not enabled.:
The compiled result does not match the input creation bytecode located at 0x4c94e89d5ec3125339906109f143673f40868df2. Compilation failed: ["Warning: This is a pre-release compiler version, please do not use it in production.\n",":6:5: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use \"constructor(...) { ... }\" instead.\n function Greeter() {\n ^ (Relevant source part starts here and spans across multiple lines).\n",":6:5: Warning: No visibility specified. Defaulting to \"public\". \n function Greeter() {\n ^ (Relevant source part starts here and spans across multiple lines).\n",":14:5: Warning: No visibility specified. Defaulting to \"public\". \n function greet() constant returns (string) {\n ^ (Relevant source part starts here and spans across multiple lines).\n"] .
pragma solidity ^0.4.24;
and I tried verifying with optimization both enabled and disabled and both times I was rejected. – Paymahn Moghadasian