I've got some code that's ultimately destined to run on a private network. I'm testing it with the lovely pyethereum, doing things like:

from ethereum import tester as t

class testMyContract(TestCase):
   def setUp(self):
      self.s = t.state()
      code = open('../mycontract.sol').read()
      self.mycontract = self.s.abi_contract(code, language='solidity', sender=t.k0)

   def testExpensiveThing(self):
     mydata = [1000, 3000, 2000, 8000]

This blows up with

  File "/usr/local/lib/python2.7/dist-packages/ethereum/tester.py", line 201, in _send
    raise TransactionFailed()

It doesn't blow up when I pass it less data, and the contract looks quite expensive, so I'm assuming it's breaking because it's running out of gas. Is there a way to pass pyethereum some settings that will allow the transaction to use more gas?

2 Answers 2


Use t.gas_limit and t.gas_price.

For gas limit, since you usually only want to set it once:

Set t.gas_limit before t.state(). Example t.gas_limit = 3000000

Otherwise can do self.s.abi_contract(code, gas=3000000,...

(You can set the gas_limit much higher for testing purposes so that you can deploy a very big contract, but best to keep it lower than the real network's block gas limit so that contracts will be deployable on the real network.)

  • Thanks, I set t.gas_limit = t.gas_limit * 10 right before calling t.state() and now it's working. Commented Mar 23, 2016 at 22:38

You can change the start gas here:

self.mycontract = self.s.abi_contract(code, gas=3000000, language='solidity', sender=t.k0)

But I'm not sure if that's the actual problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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