How to verify whether the transaction was successful

It is usually viewed through the event




event mylog(uint code);
function test()
{
…
    mylog(0);
}
发起交易后,根据eth.getTransactionReceipt()检索,结果大致如下
{
“jsonrpc”:“2.0”,
“id”:1,
“result”:{
“blockHash”:“0xde5d1584b86db40a4ea64b8474f7b6d2c693f18ead347202f3c03a0d9904c672”,
“blockNumber”:“0x186f”,
“contractAddress”:null,
“cumulativeGasUsed”:“0x92e79”,
“from”:“0xe5684e632668d1bf0a84a60d98b3e7230695f568”,
“gasUsed”:“0x10531”,
“logs”:[
{
“address”:“0xee1b3f3a4e5f2b2d3029b6b65f3684e73b437447”,
“blockHash”:“0xde5d1584b86db40a4ea64b8474f7b6d2c693f18ead347202f3c03a0d9904c672”,
“blockNumber”:“0x186f”,
“data”:“0x0000000000000000000000000000000000000000000000000000000000000000”,
“logIndex”:“0x8”,
“topics”:[],
“transactionHash”:“0x58a16df942e3fb4f7d3476c9c8af05b95368960eb43cafdb9c3ecac1c4e0d59a”,
“transactionIndex”:“0x0”
}
],
“root”:“be061b18e7f402e4f1348e345316101c2939967ea5276564e0a698bc63c07de0”,
“to”:“0xee1b3f3a4e5f2b2d3029b6b65f3684e73b437447”,
“transactionHash”:“0x58a16df942e3fb4f7d3476c9c8af05b95368960eb43cafdb9c3ecac1c4e0d59a”,
“transactionIndex”:“0x8”
}
}

If the log node in the returned result is not empty and the value of data is 0, it means that the test function in the contract is executed successfully.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325392905&siteId=291194637