MCPcopy Create free account
hub / github.com/GridPlus/client / CheckReceipt

Function CheckReceipt

src/rpc/eth.go:278–292  ·  view source on GitHub ↗

** * Check a receipt for the cumulative gas used. This will be our metric to check * if the tx threw. * * @param txhash Amount of gas used, an integer * @return 1 if the transaction went through, -1 if it threw. 0 otherwise */

(txhash string)

Source from the content-addressed store, hash-verified

276 * @return 1 if the transaction went through, -1 if it threw. 0 otherwise
277 */
278func CheckReceipt(txhash string) (int8, error) {
279 _gasUsed, err := client.Eth_gasUsed(txhash)
280 if err != nil {
281 return 0, fmt.Errorf("Error getting tx receipt: (%s)", err)
282 } else if _gasUsed == "" {
283 return 0, nil
284 }
285 _tx, _ := client.Eth_getTransactionByHash(txhash)
286 gasSent, _ := strconv.ParseUint(_tx.Gas, 0, 64)
287 gasUsed, _ := strconv.ParseUint(_gasUsed, 0, 64)
288 if gasUsed >= gasSent {
289 return -1, nil
290 }
291 return 1, nil
292}
293
294
295/**

Callers

nothing calls this directly

Calls 2

Eth_gasUsedMethod · 0.80

Tested by

no test coverage detected