Skip to content
This repository has been archived by the owner on Aug 8, 2018. It is now read-only.

Commit

Permalink
Merge pull request #151 from hackaugusto/deploy_check
Browse files Browse the repository at this point in the history
check for out-of-gas in deploy_solidity_contract
  • Loading branch information
hackaugusto authored Aug 5, 2016
2 parents b647399 + da8dd42 commit 86776e8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pyethapp/rpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,14 @@ def deploy_solidity_contract(self, sender, contract_name, all_contracts, # pyli
receipt = self.call('eth_getTransactionReceipt', '0x' + transaction_hash)

contract_address = receipt['contractAddress']
libraries[deploy_contract] = contract_address[2:] # remove the hexadecimal prefix 0x from the address
contract_address = contract_address[2:] # remove the hexadecimal prefix 0x from the address

libraries[deploy_contract] = contract_address

deployed_code = self.call('eth_getCode', contract_address, 'latest')

if deployed_code == '0x':
raise RuntimeError("Contract address has no code, check gas usage.")

hex_bytecode = solidity_resolve_symbols(contract['bin_hex'], libraries)
bytecode = hex_bytecode.decode('hex')
Expand All @@ -268,6 +275,13 @@ def deploy_solidity_contract(self, sender, contract_name, all_contracts, # pyli
receipt = self.call('eth_getTransactionReceipt', '0x' + transaction_hash)
contract_address = receipt['contractAddress']

deployed_code = self.call('eth_getCode', contract_address, 'latest')

if deployed_code == '0x':
raise RuntimeError("Deployment of {} failed. Contract address has no code, check gas usage.".format(
contract_name
))

return ContractProxy(
sender,
contract_interface,
Expand Down

0 comments on commit 86776e8

Please sign in to comment.