To deploy a contract to the network, we have more than one method, you can choose to use the mist or you can use the rpc interface. I choose the rpc interface in python. I deploy the contract like this:

contract_tx = c.create_contract(c.eth_coinbase(), compiled_code, gas = 3000000)

(I use the eth_compilesolidity command to get the compiled code). But after that when I test the contract with its inquiry function something is going wrong. The error message is shown below in the pictureenter image description here

Can somebody help me correct it?

And by contrast I deploy the same contract with mist, after getting the address I also use the rpc interface in python to do the inquiry with that mist-deployed contract and this time it works, why?

    p_attach=Popen("\Users\wzy20\Desktop\geth attach",shell=True,stdin=PIPE,stdout=PIPE,stderr=PIPE)
p_attach.communicate(input="admin.setSolc(\"C:\\\Program Files\\\Ethereum\\\solc.exe\")")
print "unlocking and deploying the game contract"
    p_attach=Popen("\Users\wzy20\Desktop\geth attach",shell=True,stdin=PIPE,stdout=PIPE,stderr=PIPE)
    contract_tx = c.create_contract(c.eth_coinbase(), compiled_code, gas = 3000000)   
    p_attach=Popen("\Users\wzy20\Desktop\geth attach",shell=True,stdin=PIPE,stdout=PIPE,stderr=PIPE)
    print "wrong password"
for x in range(100):
        print 'contract_address: '+contract_addr
        print str(x*3) + 's' + "waiting to be mined!"
  • Most likely your compiled_code is wrong. Please edit the question and add the relevant source code and steps you did create compiled_code value. – Mikko Ohtamaa Jul 16 '16 at 15:55
  • could it be something wrong about the length of the contract, for I have tested the way of contract compiling and deployment many times but with relatively short contracts, all of them work – Wang Jul 17 '16 at 7:47
  • the way I compile my code is: compiled_code=c.eth_compileSolidity(contract_source)[unicode("blackjack")][unicode("code")] where contract_source is plain texted code, and my contract is named 'blackjack' and for further deployment I use "contract_tx = c.create_contract(c.eth_coinbase(), compiled_code, gas = 3000000)" – Wang Jul 17 '16 at 7:48
  • Can you please edit the question and add the source code there as the readability of the code in comment is very poor? – Mikko Ohtamaa Jul 18 '16 at 0:51
  • Please update the question with the following information: - the contract's code - network you are using the python implementation on (private net or main net) - the compiled contract byte strings (from both the pyethapp and mist) From the current information, it's very likely that the byte code of the contract emitted by the python implementation is invalid. Without the contract code it's difficult to tell more. As a rule of thumb you should always make use of maintained packages; go-ethereum has more support a.t.m. then pyethereum. – Sebi Jul 21 '16 at 9:14

This is probably happening because you haven't mined the transaction, you have to mine (aka validate it in the blockchain) it if you want to publicly call its functions.


Check that you have enough gas (try increasing the gas limit)- I was getting the same error using ethjsonrpc, but adding another zero to my gas limit fixed this.

In general, I'm realizing that a first step in trouble-shooting a problem should be to first increase the gas limit... then double-check the code only if that doesn't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.