0

My solidity:

function Test(address to, uint amount) public {
    require(amount == 1000000000000000000);
}

In Nethereum

var r = contract.GetFunction("Test").SendTransactionAsync(<Owner Address>, <to Address>, Value).Result;
var rcpt = web3.TransactionManager.TransactionReceiptService.PollForReceiptAsync(r).Result;

The solidity will fail if I send any transaction with value that is not 1000000000000000000

I compare the differences between the successful / failure response:

BlockNumber=Nethereum.Hex.HexTypes.HexBigInteger
CumulativeGas=0.000000000000073064
GasUsed=0.000000000000073064
HasErrors=
TransactionHash=0x39a78915d2f0278399ea8e16c5b423ea150f4ec3d35122a8ba8e70b7965b9ad6
TransactionIndex=Nethereum.Hex.HexTypes.HexBigInteger
Status=

And the failure response:

BlockNumber=Nethereum.Hex.HexTypes.HexBigInteger
CumulativeGas=0.000002100000000000
GasUsed=0.000002100000000000
HasErrors=
TransactionHash=0xe2cb3949d76314f1dcd100e7232add1d3588d5849a0aa7975e5188a5beb94236
TransactionIndex=Nethereum.Hex.HexTypes.HexBigInteger
Status=

Is it true that the only way I can tell if a transaction had failed is to check the amount of gas used? If it is exhausted, means it is failed?

I really having a hard time figuring this out. Hope someone can help!

  • What about the status field – Jaime Jun 18 '18 at 11:18
  • Jaime, it is always null :( – s k Jun 18 '18 at 11:56
  • Ooops! You shouldn't be getting status field as blank. It should either be 0x01- 1 or 0x0- 0 both corresponding to success and failure respectively. – DaveIdito Jun 18 '18 at 22:02
0

Is it true that the only way I can tell if a transaction had failed is to check the amount of gas used? If it is exhausted, means it is failed?

No. Even though exhausted gas means the transaction failed but that is not inclusive of all the cases. A transaction can easilty fail even without running out of gas.

To figure out if a transaction failed or succeeded is to look for the transaction receipt. (web3.eth.getTransactionReceipt(hash_of_the_transaction)) and then look for the field status and a 0x01 means success and 0x0 means failed. To the best of my knowledge, this is the only fool-proof way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.