

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!


public static String getRevertReason(String revertReason) {String errorMethodId = "0x08c379a0"; // Numeric.toHexString(Hash.sha3("Error(string)".getBytes())).subs tring(0, 10)if (revertReason.startsWith(errorMethodId)) {return hexToAscii(revertReason.substring(274)).trim();}return "Transaction failed";}public static String hexToAscii(String hexStr) {StringBuilder output = new StringBuilder("");for (int i = 0; i < hexStr.length(); i += 2) {String str = hexStr.substring(i, i + 2);output.append((char) Integer.parseInt(str, 16));}return output.toString();}
"0x08c379a
000000000006408c379a00000000000000000000000000 00000000000000000 000000000000000000002000000000000000000000000000000000000000000 0000000000000000000001c726f6c65206e6f742070726573656e7420696e 746865207374657000000000000000000000000000000000000000000000000 00000000000000000";String reason = getRevertReason(revertReason);assertEquals(reason, "role not present in the step");}