def do_send(self, sender, to, value, data=[]): global tx_index if not sender: sender = util.contract_sha3('foo'.encode('utf-8')) # Construct `tx`. tx = { 'source': sender, 'block_index': 0, 'tx_hash': '{}{}'.format(to, tx_index), 'block_time': TIMESTAMP, 'tx_index': tx_index } tx_index += 1 tx_obj = execute.Transaction(tx, to, 1, tester.gas_limit, value, data) # Force block init. def fake_block_init(self, db): self.db = db self.timestamp = TIMESTAMP self.number = 9001 self.prevhash = 'facefeed' self.difficulty = 1337 return blocks.Block.__init__ = fake_block_init block_obj = blocks.Block(db) # Run. processblock.MULTIPLIER_CONSTANT_FACTOR = 1 success, output, gas_remained = processblock.apply_transaction( db, tx_obj, block_obj) # Decode, return result. return success, output
def get_balance(address): block = blocks.Block(db) return block.get_balance(address)
def get_storage_data(contract_id, key): block = blocks.Block(db) return block.get_storage_data(contract_id, key)