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 picture
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\")")
c=EthJsonRpc('127.0.0.1',8545)
f=open(r'C:\\Users\\wzy20\\Desktop\\blackjack\\contract.txt','r')
contract_source=f.read()
compiled_code=c.eth_compileSolidity(contract_source)[unicode("blackjack")][unicode("code")]
passwd=getpass.getpass("password:")
print "unlocking and deploying the game contract"
try:
p_attach=Popen("\Users\wzy20\Desktop\geth attach",shell=True,stdin=PIPE,stdout=PIPE,stderr=PIPE)
p_attach.communicate(input="personal.unlockAccount(eth.coinbase,\"%s\")"%passwd)
time.sleep(5)
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)
p_attach.communicate(input="personal.lockAccount(eth.coinbase)")
except:
print "wrong password"
os._exit(0)
for x in range(100):
try:
contract_addr=c.get_contract_address(contract_tx)
print 'contract_address: '+contract_addr
break
except:
x+=1
print str(x*3) + 's' + "waiting to be mined!"
compiled_codeis wrong. Please edit the question and add the relevant source code and steps you did createcompiled_codevalue. – Mikko Ohtamaa Jul 16 '16 at 15:55