Example #1
0
            def call(this, to, value=0, data='',  sender=None,
                     startgas=25000, gasprice=10*denoms.szabo):
                sender = address20(sender or this.coinbase)
                to = address20(to)
                block = this.head_candidate
                state_root_before = block.state_root
                assert block.has_parent()
                # rebuild block state before finalization
                parent = block.get_parent()
                test_block = block.init_from_parent(parent, block.coinbase,
                                                    timestamp=block.timestamp)
                for tx in block.get_transactions():
                    success, output = processblock.apply_transaction(test_block, tx)
                    assert success

                # apply transaction
                nonce = test_block.get_nonce(sender)
                tx = Transaction(nonce, gasprice, startgas, to, value, data)
                tx.sender = sender
                try:
                    success, output = processblock.apply_transaction(test_block, tx)
                except processblock.InvalidTransaction as e:
                    success = False
                assert block.state_root == state_root_before
                if success:
                    return output
                else:
                    return False
Example #2
0
 def transact(this, to, value=0, data='', sender=None,
              startgas=25000, gasprice=10*denoms.szabo):
     sender = address20(sender or this.coinbase)
     to = address20(to)
     nonce = this.pending.get_nonce(sender)
     tx = Transaction(nonce, gasprice, startgas, to, value, data)
     this.app.services.accounts.sign_tx(sender, tx)
     assert tx.sender == sender
     this.chainservice.add_transaction(tx)
     return tx
 def transact(this,
              to,
              value=0,
              data='',
              sender=None,
              startgas=25000,
              gasprice=10 * denoms.szabo):
     sender = address20(sender or this.coinbase)
     to = address20(to)
     nonce = this.pending.get_nonce(sender)
     tx = Transaction(nonce, gasprice, startgas, to, value, data)
     this.app.services.accounts.sign_tx(sender, tx)
     assert tx.sender == sender
     this.chainservice.add_transaction(tx)
     return tx
            def call(this,
                     to,
                     value=0,
                     data='',
                     sender=None,
                     startgas=25000,
                     gasprice=10 * denoms.szabo):
                sender = address20(sender or this.coinbase)
                to = address20(to)
                block = this.head_candidate
                state_root_before = block.state_root
                assert block.has_parent()
                # rebuild block state before finalization
                parent = block.get_parent()
                test_block = block.init_from_parent(parent,
                                                    block.coinbase,
                                                    timestamp=block.timestamp)
                for tx in block.get_transactions():
                    success, output = processblock.apply_transaction(
                        test_block, tx)
                    assert success

                # apply transaction
                nonce = test_block.get_nonce(sender)
                tx = Transaction(nonce, gasprice, startgas, to, value, data)
                tx.sender = sender
                try:
                    success, output = processblock.apply_transaction(
                        test_block, tx)
                except processblock.InvalidTransaction as e:
                    success = False
                assert block.state_root == state_root_before
                if success:
                    return output
                else:
                    return False