本文整理匯總了Python中web3.Web3.soliditySha3方法的典型用法代碼示例。如果您正苦於以下問題:Python Web3.soliditySha3方法的具體用法?Python Web3.soliditySha3怎麽用?Python Web3.soliditySha3使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類web3.Web3
的用法示例。
在下文中一共展示了Web3.soliditySha3方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_soliditySha3_ens
# 需要導入模塊: from web3 import Web3 [as 別名]
# 或者: from web3.Web3 import soliditySha3 [as 別名]
def test_soliditySha3_ens(self, web3, types, values, expected):
with ens_addresses(web3, {
'one.eth': "0x49EdDD3769c0712032808D86597B84ac5c2F5614",
'two.eth': "0xA6b759bBbf4B59D24acf7E06e79f3a5D104fdCE5",
}):
# when called as class method, any name lookup attempt will fail
with pytest.raises(InvalidAddress):
Web3.soliditySha3(types, values)
# when called as instance method method, ens lookups can succeed
actual = web3.soliditySha3(types, values)
assert actual == expected
示例2: hash_balance_data
# 需要導入模塊: from web3 import Web3 [as 別名]
# 或者: from web3.Web3 import soliditySha3 [as 別名]
def hash_balance_data(
transferred_amount: typing.TokenAmount,
locked_amount: typing.TokenAmount,
locksroot: typing.Locksroot,
) -> str:
return Web3.soliditySha3(
['uint256', 'uint256', 'bytes32'],
[transferred_amount, locked_amount, locksroot],
)
示例3: hash_balance_data
# 需要導入模塊: from web3 import Web3 [as 別名]
# 或者: from web3.Web3 import soliditySha3 [as 別名]
def hash_balance_data(
transferred_amount: TokenAmount,
locked_amount: TokenAmount,
locksroot: Locksroot,
) -> bytes:
assert locksroot != b''
assert len(locksroot) == 32
if transferred_amount == 0 and locked_amount == 0 and locksroot == EMPTY_HASH:
return EMPTY_HASH
return Web3.soliditySha3( # pylint: disable=no-value-for-parameter
['uint256', 'uint256', 'bytes32'],
[transferred_amount, locked_amount, locksroot],
)