Go-Ethereum

web3.py transactionReceipt 中的欄位為空

  • March 10, 2020

我獲取了一個區塊的交易收據,並對某些欄位有一些疑問。如果交易收據顯示“to”欄位為空,“contractAddress”欄位中顯示地址,是否表示指定的合約已創建?

> AttributeDict({'blockHash':
> HexBytes('0x05578d94e81075639f393dd1252deda65c6ab244e399073b6ff946d26af0dce7'),
> 'blockNumber': 8945008, **'contractAddress':
> '0x0E3A2A1f2146d86A604adc220b4967A898D7Fe07'**, 'cumulativeGasUsed':
> 9263902, 'from': '0xef536c805482FeB3D838426ED48320f77FD5F82b',
> 'gasUsed': 6928008, 'logs': [AttributeDict({'address':
> '0x0E3A2A1f2146d86A604adc220b4967A898D7Fe07', 'topics':
> [HexBytes('0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0'),
> HexBytes('0x0000000000000000000000000000000000000000000000000000000000000000'),
> HexBytes('0x000000000000000000000000ef536c805482feb3d838426ed48320f77fd5f82b')],
> 'data': '0x', 'blockNumber': 8945008, 'transactionHash':
> HexBytes('0xc599d6ea2e6d4bd9d908f887a46040338105c20d2e8a08bc457b75180a660f17'),
> 'transactionIndex': 28, 'blockHash':
> HexBytes('0x05578d94e81075639f393dd1252deda65c6ab244e399073b6ff946d26af0dce7'),
> 'logIndex': 38, 'removed': False})], 'logsBloom':
> HexBytes('0x00000002000000000000000000000000000000000000000000800000000000000002000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000001000000000000000000400000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000001000000020000000000000000000000000000000000000000000000000000000000000000000'),
> 'status': 1, **'to': None**, 'transactionHash':
> HexBytes('0xc599d6ea2e6d4bd9d908f887a46040338105c20d2e8a08bc457b75180a660f17'),
> 'transactionIndex': 28})

此外,如果在contractAddress 下沒有指定地址並且顯示一個空的日誌欄位怎麼辦。這兩種情況說明了什麼?如果日誌數組為空但我們確實有輸入數據,那麼這兩者之間的數據類型有什麼區別?據我了解日誌

$$ $$包含事件資訊,但輸入數據包含有關所呼叫方法的資訊。我對嗎?




> AttributeDict({'blockHash':
> HexBytes('0x05578d94e81075639f393dd1252deda65c6ab244e399073b6ff946d26af0dce7'),
> 'blockNumber': 8945008, **'contractAddress': None**,
> 'cumulativeGasUsed': 9284902, 'from':
> '0xddcca96aF7Ff342f9a945f2430D1d6162CA05BeA', 'gasUsed': 21000,
> **'logs': []**, 'logsBloom': HexBytes('0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'),
> 'status': 1, 'to': '0x400592202fC8b27Cc4bC19a88D00dCA590e77799',
> 'transactionHash':
> HexBytes('0x5d7ea4017967e5a190cf283f04675f7b15fd8218b25db20a13f3747181d9ce9c'),
> 'transactionIndex': 29})```

如果交易回執顯示該to欄位為空且該contractAddress欄位中有地址,是否表示指定的合約已創建?

是的,這意味著在contractAddress欄位中指定的地址部署了合約。而恰恰相反意味著交易被發送到已經部署在to欄位中指定地址的合約。

另外,如果沒有指定地址contractAddress並顯示一個空logs欄位怎麼辦?

如上所述,交易被發送到已經部署的合約。並且該logs欄位為空的事實意味著在事務期間沒有發出任何事件。

引用自:https://ethereum.stackexchange.com/questions/80474