使用web3.py将元组参数传递给智能合约



我正在使用web3.py将元组类型参数传递给智能合约

{'considerationToken': '0x0000000000000000000000000000000000000000', 'considerationIdentifier': 0, 'considerationAmount': 1950000000000000, 'offerer': '0xf6d4434b802877d7f17c3383ce0deeef85b3a1eb', 'zone': '0x0000000000000000000000000000000000000000', 'offerToken': '0x3203203Db85E0980e3E08A1Aac083FC4DECF6EDA', 'offerIdentifier': 2, 'offerAmount': 1, 'basicOrderType': 2, 'startTime': 1665136887, 'endTime': 1667815287, 'zoneHash': '0x0000000000000000000000000000000000000000000000000000000000000000', 'salt': '0x360c6ebe00000000000000000000000000000000000000003f4e9ce90a9dc88a', 'offererConduitKey': '0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000', 'fulfillerConduitKey': '0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000', 'totalOriginalAdditionalRecipients': 1, 'additionalRecipients': [{'amount': 250000000000000, 'recipient': '0x0000a26b00c1f0df003000390027140000faa719'}], 'signature': '0x47d29ea6aadde9ce7b3a2c6f3cce560697200b103be114747e453e0989f42d7360a40a4e62941371549be78fe00232ea6c407d20346bb0811ed6610513b338fb1c'}

这是我生成的参数,可以在"etherscan"中正常使用,但函数中报告了错误,下面是我的代码。

basic_order_parameters = {
"considerationToken": "0x0000000000000000000000000000000000000000",
"considerationIdentifier":0,
"considerationAmount":1950000000000000,
"offerer": "0xf6d4434b802877d7f17c3383ce0deeef85b3a1eb",
"zone": "0x0000000000000000000000000000000000000000",
"offerToken": "0x3203203Db85E0980e3E08A1Aac083FC4DECF6EDA",
"offerIdentifier":2,
"offerAmount":1,
"basicOrderType": 2,
"startTime": 1665136887,
"endTime": 1667815287,
"zoneHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"salt": "0x360c6ebe00000000000000000000000000000000000000003f4e9ce90a9dc88a",
"offererConduitKey": "0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000",
"fulfillerConduitKey":"0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000",
"totalOriginalAdditionalRecipients": 1,
"additionalRecipients": additionalRecipients3,
"signature": "0x47d29ea6aadde9ce7b3a2c6f3cce560697200b103be114747e453e0989f42d7360a40a4e62941371549be78fe00232ea6c407d20346bb0811ed6610513b338fb1c"
}

这是错误消息

web3.exceptions.ValidationError:
Could not identify the intended function with name `fulfillBasicOrder`, positional argument(s) of type `(<class 'dict'>,)` and keyword argument(s) of type `{}`.
Found 1 function(s) with the name `fulfillBasicOrder`: ['fulfillBasicOrder(tuple)']
Function invocation failed due to no matching argument types.

这是智能合约地址:https://goerli.etherscan.io/address/0x00000000006c3852cbef3e08e8df289169ede581

错误显示您正在尝试使用Dict而不是Tuple。

你这样试过吗?

myContract.functions.fulfillBasicOrder(
"0x0000000000000000000000000000000000000000",
0,
1950000000000000,
"0xf6d4434b802877d7f17c3383ce0deeef85b3a1eb",
"0x0000000000000000000000000000000000000000",
"0x3203203Db85E0980e3E08A1Aac083FC4DECF6EDA",
2,
1,
2,
1665136887,
1667815287,
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x360c6ebe00000000000000000000000000000000000000003f4e9ce90a9dc88a",
"0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000",
"0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000",
1,
additionalRecipients3,
"0x47d29ea6aadde9ce7b3a2c6f3cce560697200b103be114747e453e0989f42d7360a40a4e62941371549be78fe00232ea6c407d20346bb0811ed6610513b338fb1c"
)

最新更新