1

Sample code below (simplified for illustrative purposes only):

var a = new ManagedAccount(mOwner, mOwnerPwd);
var w = new Web3(a, mNodeUrl);
w.TransactionManager.DefaultGas = mGasLimit;
w.TransactionManager.DefaultGasPrice = mGasPrice;
Contract c = w.Eth.GetContract(mVAbi, mVAdd);

var r = c.GetFunction("issueCoin").
    SendTransactionAsync(mOwner, To, Value).Result;

Thread.Sleep(10000);

var rcpt = w.TransactionManager.TransactionReceiptService.PollForReceiptAsync(r).Result;

No matter how long I sleep, the rcpt.Status is always NULL, even when I deliberately let the transaction runs out of gas and failed, the rcpt.Status is still NULL.

My question now is, how can I check and ensure a transaction is successful?

s k
  • 886
  • 1
  • 10
  • 22
  • Have you tried using filters? I'm sorry I don't have experience with nethereum, but seems like that's what you need and then get the filter logs or listen to changes. – DaveIdito Jun 19 '18 at 03:28
  • Daveldito, the Transfer event only tells the From, To and Value but didn't have status to indicates the transaction is successful. Can I assume as long as I received the Transfer event means that my transaction had already succeed? – s k Jun 19 '18 at 07:08
  • @s k the event log includes the transaction hash in which the event was logged, then using the transaction hash you can find the transaction receipt and read the status. – DaveIdito Jun 19 '18 at 07:19
  • Based on this answer https://ethereum.stackexchange.com/questions/4085/is-it-a-good-practice-to-log-an-event-every-time-i-throw-in-solidity , yes that means the transaction was successful. But I hope you do realize there's a difference between event and transaction receipt. – DaveIdito Jun 19 '18 at 07:22

0 Answers0