How to use hexbytes - 10 common examples

To help you get started, we’ve selected a few hexbytes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ethereum / web3.py / web3 / _utils / module_testing / web3_module.py View on Github external
    @pytest.mark.parametrize(
        'types, values, expected',
        (
            (
                ['address'],
                ['one.eth'],
                HexBytes("0x2ff37b5607484cd4eecf6d13292e22bd6e5401eaffcc07e279583bc742c68882"),
            ),
            (
                ['address[]'],
                [['one.eth', 'two.eth']],
                HexBytes("0xb98565c0c26a962fd54d93b0ed6fb9296e03e9da29d2281ed3e3473109ef7dde"),
            ),
        ),
    )
    def test_solidityKeccak_ens(
        self, web3: "Web3", types: Sequence[TypeStr], values: Sequence[str], expected: HexBytes
    ) -> None:
        with ens_addresses(web3, {
            'one.eth': cast(ChecksumAddress, "0x49EdDD3769c0712032808D86597B84ac5c2F5614"),
            'two.eth': cast(ChecksumAddress, "0xA6b759bBbf4B59D24acf7E06e79f3a5D104fdCE5"),
        }):
            # when called as class method, any name lookup attempt will fail
            with pytest.raises(InvalidAddress):
                Web3.solidityKeccak(types, values)

            # when called as instance method, ens lookups can succeed
            actual = web3.solidityKeccak(types, values)
github ethereum / web3.py / web3 / _utils / module_testing / web3_module.py View on Github external
                HexBytes("0x30f95d210785601eb33ae4d53d405b26f920e765dff87cca8e9a4aec99f82671"),
            ),
            (
                ['bool', 'uint16'],
                [True, 299],
                HexBytes("0xed18599ccd80ee9fae9a28b0e34a5573c3233d7468f808fd659bc171cf0b43bd"),
            ),
            (
                ['int256'],
                [-10],
                HexBytes("0xd6fb717f7e270a360f5093ce6a7a3752183e89c9a9afe5c0cb54b458a304d3d5"),
            ),
            (
                ['int256'],
                [10],
                HexBytes("0xc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a8"),
            ),
github ethereum / web3.py / web3 / _utils / module_testing / web3_module.py View on Github external
                HexBytes("0xf3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3"),
            ),
            (
                ['address[]'],
                [[
                    "0x49EdDD3769c0712032808D86597B84ac5c2F5614",
                    "0xA6b759bBbf4B59D24acf7E06e79f3a5D104fdCE5",
                ]],
                HexBytes("0xb98565c0c26a962fd54d93b0ed6fb9296e03e9da29d2281ed3e3473109ef7dde"),
            ),
            (
                ['address[]'],
                [[
                    "0x49EdDD3769c0712032808D86597B84ac5c2F5614",
                    "0xa6b759bbbf4b59d24acf7e06e79f3a5d104fdce5",
                ]],
                InvalidAddress,
github AlisProject / serverless-application / tests / handlers / me / wallet / token / allhistories / create / test_me_wallet_token_allhistories_create.py View on Github external
'logIndex': 0,
              'topics': [HexBytes('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'),
                         HexBytes('0x0000000000000000000000001111111111111111111111111111111111111111'),
                         HexBytes('0x0000000000000000000000000000000000000000000000000000000000000000')],
              'transactionHash': HexBytes('0xf45f335a0bb17d112e870f98218ebd5159e5d7ab9f1739677d7c0b3df4879446'),
              'transactionIndex': 0,
              'transactionLogIndex': '0x0',
              'type': 'mined'}],
            [{'address': '0x1383B25f9ba231e3a1a1E45c0b5689d778D44AD5',
              'blockHash': HexBytes('0xf32e073349e4ca49c5e193b161ea1b9ba7dc9c2a9bf1271725c99bb5c690bba8'),
              'blockNumber': 836877, 'data': '0x0000000000000000000000000000000000000000000000000de0b6b3a7640000',
              'logIndex': 0,
              'topics': [HexBytes('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'),
                         HexBytes('0x0000000000000000000000000000000000000000000000000000000000000000'),
                         HexBytes('0x0000000000000000000000001111111111111111111111111111111111111111')],
              'transactionHash': HexBytes('0xf45f335a0bb17d112e870f98218ebd5159e5d7ab9f1739677d7c0b3df4879457'),
              'transactionIndex': 0,
              'transactionLogIndex': '0x0',
              'type': 'mined'},
             {'address': '0x1383B25f9ba231e3a1a1E45c0b5689d778D44AD5',
              'blockHash': HexBytes('0xf32e073349e4ca49c5e193b161ea1b9ba7dc9c2a9bf1271725c99bb5c690bbc8'),
              'blockNumber': 836877, 'data': '0x0000000000000000000000000000000000000000000000000de0b6b3a7640000',
              'logIndex': 0,
              'topics': [HexBytes('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'),
                         HexBytes('0x0000000000000000000000000000000000000000000000000000000000000000'),
                         HexBytes('0x0000000000000000000000001111111111111111111111111111111111111111')],
              'transactionHash': HexBytes('0xf45f335a0bb17d112e870f98218ebd5159e5d7ab9f1739677d7c0b3df4873457'),
              'transactionIndex': 0,
              'transactionLogIndex': '0x0',
              'type': 'mined'}],
            [{'address': '0x1383B25f9ba231e3a1a1E45c0b5689d778D44AD5',
              'blockHash': HexBytes('0xf32e073349e4ca49c5e193b161ea1b9ba7dc9c2a9bf1271725c99bb5c690bba9'),
github ethereum / web3.py / tests / core / shh-module / test_shh_filter.py View on Github external
web3.shh.post({
        'sig': sender,
        'powTarget': 2.5,
        'powTime': 2,
        'payload': payloads[1],
        'topic': topic,
        'pubKey': receiver_pub
    })
    time.sleep(1)

    received_messages = shh_filter.get_new_entries()
    assert len(received_messages) == 1

    message = received_messages[0]

    assert message["payload"] == HexBytes(payloads[1])
    assert message["topic"] == HexBytes(topic)
github Lamden / clove / tests / constants.py View on Github external
'to': '0xce07aB9477BC20790B88B398A2A9e0F626c7D263',
    'transactionIndex': 1,
    'v': 28,
    'value': 1000000000000000
})

eth_unsupported_transaction = AttributeDict({
    'input': (
        '0xeb7ae1ed000000000000000000000000000000000000000000000000000000005abe25ea10ff9'
        '72f3d8181f603aa7f6b4bc172de730fec2b00000000000000000000000000000000000000000000'
        '0000d867f293ba129629a9f9355fa285b8d3711a9092'
    ),
})

eth_redeem_tranaction = AttributeDict({
    'blockHash': HexBytes('0x579c835eb257089492b99c44aae33660cd5efd83297036a4d0d6c11c8921ae8c'),
    'blockNumber': 8398155,
    'chainId': None,
    'condition': None,
    'creates': None,
    'from': '0xd867f293Ba129629a9f9355fa285B8D3711a9092',
    'gas': 100000,
    'gasPrice': 2000000000,
    'hash': HexBytes('0x65320e57b9d18ec08388896b029ad1495beb7a57c547440253a1dde01b4485f1'),
    'input': '0xeda1122cbc2424e1dcdd2e425c555bcea35a54fd27cf540e60f18366e153e3fb7cf4490c',
    'nonce': 146,
    'publicKey': HexBytes(
        '0x579c6126677857d4d5a227ed47efbd9742e26f60449e8ea6a536c0dd9b2fb6fb14e0fddc7cb06fd78d2c6c3ef4d1b72e48809650'
        '4817ed7ac252b2453cbfab56'
    ),
    'r': HexBytes('0xcde19e4d2d78e196ecc8dff5ba6e2c90bfc6be93241e8dd2584734e870e6b677'),
    'raw': HexBytes(
github Lamden / clove / tests / constants.py View on Github external
eth_initial_transaction = AttributeDict({
    'blockHash': HexBytes('0x111346453964a0df4fcd50ac759231f4f90a858c6ab62255e7c75089b22b0b40'),
    'blockNumber': 8388823,
    'chainId': None,
    'condition': None,
    'creates': None,
    'from': '0x999F348959E611F1E9eab2927c21E88E48e6Ef45',
    'gas': 140502,
    'gasPrice': 1000000000,
    'hash': HexBytes('0xcf64ef4d0449cf7a78d2be1c1f7225dffb11dded98a58d569ebcc6e883ce9f2b'),
    'input': '0x7337c993000000000000000000000000000000000000000000000000000000005b782cfaed2e6fe492005de2dd82e84d38448'
             '467d632e81c000000000000000000000000000000000000000000000000d867f293ba129629a9f9355fa285b8d3711a90920000'
             '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
             '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    'nonce': 283,
    'publicKey': HexBytes(
        '0x76c4f5810736d1d9b9964863abc339dce70ace058db5c820e5fdec26e0840f36f9adcb150e5216213bc301f3a6b71a178'
        'c81ddd34a361d696c8cb03970590d4f'
    ),
    'r': HexBytes('0x68e2bbdd4cb4e989854a87aa8964c65b3bf28f68183f73f905ab8841db690cbb'),
    'raw': HexBytes(
        '0xf9013282011b843b9aca00830224d694ce07ab9477bc20790b88b398a2a9e0f626c7d26387038d7ea4c68000b8c47337c993000000'
        '000000000000000000000000000000000000000000000000005b782cfaed2e6fe492005de2dd82e84d38448467d632e81c0000000000'
        '00000000000000000000000000000000000000d867f293ba129629a9f9355fa285b8d3711a9092000000000000000000000000000000'
        '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
        '0000000000000000000000000000000000000000000000000000001ca068e2bbdd4cb4e989854a87aa8964c65b3bf28f68183f73f905'
        'ab8841db690cbba0227712dc5c204041cc8c44facac023c457725acc905b2db311b1176cd53836e0'
    ),
    's': HexBytes('0x227712dc5c204041cc8c44facac023c457725acc905b2db311b1176cd53836e0'),
    'standardV': 1,
    'to': '0xce07aB9477BC20790B88B398A2A9e0F626c7D263',
    'transactionIndex': 1,
github Lamden / clove / tests / constants.py View on Github external
'r': HexBytes('0xcde19e4d2d78e196ecc8dff5ba6e2c90bfc6be93241e8dd2584734e870e6b677'),
    'raw': HexBytes(
        '0xf88981928477359400830186a094ce07ab9477bc20790b88b398a2a9e0f626c7d26380a4eda1122cbc2424e1dcdd2e425c555bce'
        'a35a54fd27cf540e60f18366e153e3fb7cf4490c1ba0cde19e4d2d78e196ecc8dff5ba6e2c90bfc6be93241e8dd2584734e870e6b6'
        '77a02fe805af66d13352198a8b19b53ee1dc27671b76a4626af8cead8211537ea7d9'
    ),
    's': HexBytes('0x2fe805af66d13352198a8b19b53ee1dc27671b76a4626af8cead8211537ea7d9'),
    'standardV': 0,
    'to': '0xce07aB9477BC20790B88B398A2A9e0F626c7D263',
    'transactionIndex': 0,
    'v': 27,
    'value': 0
})

token_initial_transaction = AttributeDict({
    'blockHash': HexBytes('0x0cc3bd2154a33a91362ff719c1f891aac2e3bb5ecd298878dd08bbd6c562a9e4'),
    'blockNumber': 8399513,
    'chainId': None,
    'condition': None,
    'creates': None,
    'from': '0x999F348959E611F1E9eab2927c21E88E48e6Ef45',
    'gas': 180590,
    'gasPrice': 1000000000,
    'hash': HexBytes('0x224818e4390e6d4e24b18e19a268825c0bbc649ab3e93dcb446328973dc7914b'),
    'input': '0x7337c993000000000000000000000000000000000000000000000000000000005b7962b834378f0187488d019d3e0151f2fe'
             '3d3672ca310e000000000000000000000000000000000000000000000000d867f293ba129629a9f9355fa285b8d3711a909200'
             '000000000000000000000053e546387a0d054e7ff127923254c0a679da6dbf0000000000000000000000000000000000000000'
             '00000000000000000000000100000000000000000000000000000000000000000000003635c9adc5dea00000',
    'nonce': 287,
    'publicKey': HexBytes(
        '0x76c4f5810736d1d9b9964863abc339dce70ace058db5c820e5fdec26e0840f36f9adcb150e5216213bc301f3a6b71a178c81ddd34'
        'a361d696c8cb03970590d4f'
github Lamden / clove / tests / constants.py View on Github external
'from': '0x999F348959E611F1E9eab2927c21E88E48e6Ef45',
    'gas': 300000,
    'gasPrice': 4000000000,
    'hash': HexBytes('0x270cc74bf60fd0d37806b000a11da972ce240fa7478e38d8b44b6793ddd3284d'),
    'input': (
        '0x52f50db7000000000000000000000000000000000000000000000000000000005ae3085f7780c856405b3ce2e2c'
        '717857b3439c545316974000000000000000000000000000000000000000000000000d867f293ba129629a9f9355f'
        'a285b8d3711a909200000000000000000000000053e546387a0d054e7ff127923254c0a679da6dbf0000000000000'
        '000000000000000000000000000000000000853a0d2313c0000'
    ),
    'nonce': 58,
    'publicKey': HexBytes(
        '0x76c4f5810736d1d9b9964863abc339dce70ace058db5c820e5fdec26e0840f36f9adcb150e5216213bc301f3a6b'
        '71a178c81ddd34a361d696c8cb03970590d4f'
    ),
    'r': HexBytes('0x579ab66e7cab564d9c67e50c571b1e36afe0095d9d539d4cd3dd871893316201'),
    'raw': HexBytes(
        '0xf901093a84ee6b2800830493e0947657ca877fac31d20528b473162e39b6e152fd2e80b8a452f50db7000000000'
        '000000000000000000000000000000000000000000000005ae3085f7780c856405b3ce2e2c717857b3439c5453169'
        '74000000000000000000000000000000000000000000000000d867f293ba129629a9f9355fa285b8d3711a9092000'
        '00000000000000000000053e546387a0d054e7ff127923254c0a679da6dbf00000000000000000000000000000000'
        '00000000000000000853a0d2313c00001ba0579ab66e7cab564d9c67e50c571b1e36afe0095d9d539d4cd3dd87189'
        '3316201a05a1a325b46b19eb5f43a2989daf5c92aac1ca48187866a3268ff47cc4e88911e'
    ),
    's': HexBytes('0x5a1a325b46b19eb5f43a2989daf5c92aac1ca48187866a3268ff47cc4e88911e'),
    'standardV': 0,
    'to': '0x7657Ca877Fac31D20528B473162E39B6E152fd2e',
    'transactionIndex': 0,
    'v': 27,
    'value': 0
})
github Lamden / clove / tests / constants.py View on Github external
'00000000000000000000000100000000000000000000000000000000000000000000003635c9adc5dea00000',
    'nonce': 287,
    'publicKey': HexBytes(
        '0x76c4f5810736d1d9b9964863abc339dce70ace058db5c820e5fdec26e0840f36f9adcb150e5216213bc301f3a6b71a178c81ddd34'
        'a361d696c8cb03970590d4f'
    ),
    'r': HexBytes('0xe184d8b211a07bd1fea3f7b373e18624e2973db797f512c004cf3dd131994fce'),
    'raw': HexBytes(
        '0xf9012b82011f843b9aca008302c16e94ce07ab9477bc20790b88b398a2a9e0f626c7d26380b8c47337c9930000000000000000000'
        '00000000000000000000000000000000000005b7962b834378f0187488d019d3e0151f2fe3d3672ca310e0000000000000000000000'
        '00000000000000000000000000d867f293ba129629a9f9355fa285b8d3711a909200000000000000000000000053e546387a0d054e7'
        'ff127923254c0a679da6dbf000000000000000000000000000000000000000000000000000000000000000100000000000000000000'
        '000000000000000000000000003635c9adc5dea000001ba0e184d8b211a07bd1fea3f7b373e18624e2973db797f512c004cf3dd1319'
        '94fcea05bc5daa0d693604f2c645ed7d7cfa53f6ebe8f4f6bb3e45a98f57946050a5503'
    ),
    's': HexBytes('0x5bc5daa0d693604f2c645ed7d7cfa53f6ebe8f4f6bb3e45a98f57946050a5503'),
    'standardV': 0,
    'to': '0xce07aB9477BC20790B88B398A2A9e0F626c7D263',
    'transactionIndex': 11,
    'v': 27,
    'value': 0
})


etherscan_internal_transactions = {
    "message": "OK",
    "result": [
        {
            "blockNumber": "6628836",
            "contractAddress": "",
            "errCode": "",
            "from": "0x9f7e5402ed0858ea0c5914d44b900a42c89547b8",

hexbytes

hexbytes: Python `bytes` subclass that decodes hex, with a readable console output

MIT
Latest version published 5 months ago

Package Health Score

86 / 100
Full package analysis

Popular hexbytes functions