Exemple #1
0
 async def call(self,
                to: str,
                data: str,
                tag: Union[int, str] = 'latest') -> str:
     """Executes a new message call immediately without creating a transaction on the block chain."""
     return await self._get(
         action='eth_call',
         to=check_hex(to),
         data=check_hex(data),
         tag=check_tag(tag),
     )
Exemple #2
0
 async def tx_by_number_and_index(self,
                                  index: Union[int, str],
                                  tag: Union[int, str] = 'latest') -> Dict:
     """Returns information about a transaction by block number and transaction index position."""
     return await self._get(
         action='eth_getTransactionByBlockNumberAndIndex',
         index=check_hex(index),
         tag=check_tag(tag),
     )
Exemple #3
0
 async def uncle_block_by_number_and_index(
         self,
         index: Union[int, str],
         tag: Union[int, str] = 'latest') -> Dict:
     """Returns information about a uncle by block number."""
     return await self._get(
         action='eth_getUncleByBlockNumberAndIndex',
         index=check_hex(index),
         tag=check_tag(tag),
     )
Exemple #4
0
    async def estimate_gas(self, to: str, value: str, gas_price: str,
                           gas: str) -> str:
        """Makes a call or transaction, which won't be added to the blockchain and returns the used gas.

        Can be used for estimating the used gas.
        """
        return await self._get(
            action='eth_estimateGas',
            to=check_hex(to),
            value=value,
            gasPrice=gas_price,
            gas=gas,
        )
Exemple #5
0
 async def tx_receipt(self, txhash: str) -> Dict:
     """Returns the receipt of a transaction by transaction hash."""
     return await self._get(
         action='eth_getTransactionReceipt',
         txhash=check_hex(txhash),
     )
Exemple #6
0
 async def tx_by_hash(self, txhash: Union[int, str]) -> Dict:
     """Returns the information about a transaction requested by transaction hash."""
     return await self._get(
         action='eth_getTransactionByHash',
         txhash=check_hex(txhash),
     )
Exemple #7
0
def test_check_hex():
    assert check_hex(123) == '0x7b'
    assert check_hex(0x7b) == '0x7b'
    assert check_hex('0x7b') == '0x7b'
    with pytest.raises(ValueError):
        check_hex('wrong')