当前位置: 首页>>代码示例>>Python>>正文


Python Transaction.sender方法代码示例

本文整理汇总了Python中ethereum.transactions.Transaction.sender方法的典型用法代码示例。如果您正苦于以下问题:Python Transaction.sender方法的具体用法?Python Transaction.sender怎么用?Python Transaction.sender使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ethereum.transactions.Transaction的用法示例。


在下文中一共展示了Transaction.sender方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_call

# 需要导入模块: from ethereum.transactions import Transaction [as 别名]
# 或者: from ethereum.transactions.Transaction import sender [as 别名]
def test_call(block, sender, to, data='', gasprice=0, value=0):
    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
    startgas = block.gas_limit - block.gas_used
    gasprice = 0
    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:
        log.debug('test_call failed', error=e)
        return None
开发者ID:1600,项目名称:hydrachain,代码行数:29,代码来源:native_contracts.py

示例2: call

# 需要导入模块: from ethereum.transactions import Transaction [as 别名]
# 或者: from ethereum.transactions.Transaction import sender [as 别名]
            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
开发者ID:Arachnid,项目名称:pyethapp,代码行数:30,代码来源:console_service.py

示例3: call

# 需要导入模块: from ethereum.transactions import Transaction [as 别名]
# 或者: from ethereum.transactions.Transaction import sender [as 别名]
    def call(self, data, block_id=None):
        block = self.json_rpc_server.get_block(block_id)
        state_root_before = block.state_root

        # rebuild block state before finalization
        if block.has_parent():
            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
        else:
            original = block.snapshot()
            original['journal'] = deepcopy(original['journal'])  # do not alter original journal
            test_block = ethereum.blocks.genesis(block.db)
            test_block.revert(original)

        # validate transaction
        if not isinstance(data, dict):
            raise BadRequestError('Transaction must be an object')
        to = address_decoder(data['to'])
        try:
            startgas = quantity_decoder(data['gas'])
        except KeyError:
            startgas = block.gas_limit - block.gas_used
        try:
            gasprice = quantity_decoder(data['gasPrice'])
        except KeyError:
            gasprice = 0
        try:
            value = quantity_decoder(data['value'])
        except KeyError:
            value = 0
        try:
            data_ = data_decoder(data['data'])
        except KeyError:
            data_ = b''
        try:
            sender = address_decoder(data['from'])
        except KeyError:
            sender = '\x00' * 20

        # 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
开发者ID:ychaim,项目名称:pyethapp,代码行数:60,代码来源:jsonrpc.py

示例4: create_transaction

# 需要导入模块: from ethereum.transactions import Transaction [as 别名]
# 或者: from ethereum.transactions.Transaction import sender [as 别名]
def create_transaction(
        web3: Web3,
        from_: str,
        to: str,
        data: bytes = b'',
        nonce_offset: int = 0,
        value: int = 0,
        gas_price: Union[int, None] = None,
        gas_limit: int = NETWORK_CFG.POT_GAS_LIMIT
) -> Transaction:
    if gas_price is None:
        gas_price = NETWORK_CFG.GAS_PRICE
    nonce = web3.eth.getTransactionCount(from_, 'pending') + nonce_offset
    tx = Transaction(nonce, gas_price, gas_limit, to, value, data)
    tx.sender = decode_hex(from_)
    return tx
开发者ID:AlphaX-IBS,项目名称:microraiden,代码行数:18,代码来源:contract.py

示例5: call

# 需要导入模块: from ethereum.transactions import Transaction [as 别名]
# 或者: from ethereum.transactions.Transaction import sender [as 别名]
    def call(self, data, block_id=None):
        block = self.json_rpc_server.get_block(block_id)
        # 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

        # validate transaction
        if not isinstance(data, dict):
            raise BadRequestError('Transaction must be an object')
        to = address_decoder(data['to'])
        try:
            startgas = quantity_decoder(data['gas'])
        except KeyError:
            startgas = block.gas_limit - block.gas_used
        try:
            gasprice = quantity_decoder(data['gasPrice'])
        except KeyError:
            gasprice = 0
        try:
            value = quantity_decoder(data['value'])
        except KeyError:
            value = 0
        try:
            data_ = data_decoder(data['data'])
        except KeyError:
            data_ = b''
        try:
            sender = address_decoder(data['from'])
        except KeyError:
            sender = '\x00' * 20
        # initialize transaction
        nonce = block.get_nonce(sender)
        tx = Transaction(nonce, gasprice, startgas, to, value, data_)
        tx.sender = sender
        # apply transaction
        try:
            success, output = processblock.apply_transaction(test_block, tx)
        except processblock.InvalidTransaction:
            success = False
        if success:
            return output
        else:
            return False
开发者ID:danielnovy,项目名称:test,代码行数:49,代码来源:jsonrpc.py


注:本文中的ethereum.transactions.Transaction.sender方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。