Web3Swift icon indicating copy to clipboard operation
Web3Swift copied to clipboard

Missing getting transaction status

Open rockfridrich opened this issue 7 years ago • 1 comments

Once the transaction is sent to the network it has status pending unless it is mined in one of next blocks.

We can get transaction status by sending two remote requests:

  1. Send eth_getTransactionByHash request. It will return null in case transaction is not mined yet. Or if it is mined we will get basic transaction info and block in which it was mined. Result example:
{"blockHash":"0xf200a38f24d0cc834183b3ab907a4f1f1758fed85182ee22e3d9d40d0a01afc2","blockNumber":"0x503fe1","from":"0xe35d276812001e33e3a8f6f445e2d1e90ff86f1c","gas":"0x8362","gasPrice":"0x12a05f200","hash":"0x9cd20a2a45a341e4056654fc69144f0b8c09b37f8016eac4009c65813b4adf78","input":"0x","nonce":"0x42","to":"0x9e8fab94cada52a584ec6f10042c3bb165e79114","transactionIndex":"0xa9","value":"0x38d7ea4c68000","v":"0x25","r":"0xcc85854e457c53251febe5064732795328560ee1a2f083e8b893f7247a9eafdc","s":"0x6a6369fc59395ce9dc041b442fb5bc379e442c6f628ba2a32b0245508bc996d3"}
  1. Send eth_getTransactionReceipt request. It will return null in case transaction is not mined yet. Or if it is mined we will get full transaction info and block in which it was mined.
  • For example what address was assigned to the deployed contract contractAddress.
  • How much gas was used gasUsed
  • transactionIndex in the block
  • Was it executed succesfully or not status (Note: It was introduced not long ago and for older transaction we do not have such field)
  • We can get transaction logs. We will need it later.
    Result example:
{"blockHash":"0xf200a38f24d0cc834183b3ab907a4f1f1758fed85182ee22e3d9d40d0a01afc2","blockNumber":"0x503fe1","contractAddress":null,"cumulativeGasUsed":"0x4492de","from":"0xe35d276812001e33e3a8f6f445e2d1e90ff86f1c","gasUsed":"0x5797","logs":[{"address":"0x9e8fab94cada52a584ec6f10042c3bb165e79114","topics":["0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c"],"data":"0x000000000000000000000000e35d276812001e33e3a8f6f445e2d1e90ff86f1c00000000000000000000000000000000000000000000000000038d7ea4c68000","blockNumber":"0x503fe1","transactionHash":"0x9cd20a2a45a341e4056654fc69144f0b8c09b37f8016eac4009c65813b4adf78","transactionIndex":"0xa9","blockHash":"0xf200a38f24d0cc834183b3ab907a4f1f1758fed85182ee22e3d9d40d0a01afc2","logIndex":"0x22","removed":false}],"logsBloom":"0x00000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000400000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000","status":"0x1","to":"0x9e8fab94cada52a584ec6f10042c3bb165e79114","transactionHash":"0x9cd20a2a45a341e4056654fc69144f0b8c09b37f8016eac4009c65813b4adf78","transactionIndex":"0xa9"}

We need to implement both of this remote procedures and domain logic for fetching transaction status.

rockfridrich avatar Mar 15 '18 11:03 rockfridrich

@biboran/z please, pay attention to this issue

0crat avatar Mar 15 '18 12:03 0crat