예제 #1
0
 def send_transaction(self, transaction):
     from ethereum import tester
     validate_transaction(transaction)
     _send_evm_transaction(
         tester_module=tester,
         evm=self.evm,
         transaction=transaction,
     )
     return self.evm.last_tx.hash
예제 #2
0
    def estimate_gas(self, transaction):
        from ethereum import tester
        validate_transaction(transaction)

        snapshot = self.take_snapshot()
        _estimate_evm_transaction(
            tester_module=tester,
            evm=self.evm,
            transaction=transaction,
        )
        txn_hash = self.evm.last_tx.hash
        receipt = self.get_transaction_receipt(txn_hash)
        self.revert_to_snapshot(snapshot)
        return receipt['gas_used']
예제 #3
0
    def call(self, transaction, block_number="latest"):
        from ethereum import tester
        validate_transaction(transaction)

        if block_number != "latest":
            raise NotImplementedError("Block number must be 'latest'.")

        snapshot = self.take_snapshot()
        output = _call_evm_transaction(
            tester_module=tester,
            evm=self.evm,
            transaction=transaction,
        )
        self.revert_to_snapshot(snapshot)
        return output
예제 #4
0
def _send_transaction(evm, raw_transaction):
    validate_transaction(raw_transaction)

    transaction = _format_transaction(evm, raw_transaction)
    output = evm.tx(**transaction)
    return output