@@ -39,12 +39,14 @@ class AleoNetworkClient {
39
39
headers : { [ key : string ] : string } ;
40
40
account : Account | undefined ;
41
41
ctx : { [ key : string ] : string } ;
42
+ debugMode : boolean ;
42
43
readonly network : string ;
43
44
44
45
constructor ( host : string , options ?: AleoNetworkClientOptions ) {
45
46
this . host = host + "/%%NETWORK%%" ;
46
47
this . network = "%%NETWORK%%" ;
47
48
this . ctx = { } ;
49
+ this . debugMode = true ;
48
50
49
51
if ( options && options . headers ) {
50
52
this . headers = options . headers ;
@@ -101,6 +103,24 @@ class AleoNetworkClient {
101
103
this . host = host + "/%%NETWORK%%" ;
102
104
}
103
105
106
+ /**
107
+ * Set debug mode for the networkClient. When this mode is enabled, if Aleo network nodes report failures after
108
+ * calling the `submitTransaction` method, nodes will report debug information as to why the transaction failed.
109
+ *
110
+ * @param {boolean } debugMode Set debug mode for the networkClient.
111
+ * @example
112
+ * import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
113
+ *
114
+ * // Create a networkClient
115
+ * const networkClient = new AleoNetworkClient();
116
+ *
117
+ * // Set debug mode to true
118
+ * networkClient.setDebugMode(true);
119
+ **/
120
+ setDebugMode ( debugMode : boolean ) {
121
+ this . debugMode = debugMode ;
122
+ }
123
+
104
124
/**
105
125
* Set a header in the `AleoNetworkClient`s header map
106
126
*
@@ -1538,8 +1558,9 @@ class AleoNetworkClient {
1538
1558
? transaction . toString ( )
1539
1559
: transaction ;
1540
1560
try {
1561
+ const endpoint = this . debugMode ? "transaction/broadcast?debug=true" : "transaction/broadcast" ;
1541
1562
const response = await retryWithBackoff ( ( ) =>
1542
- this . _sendPost ( this . host + "/transaction/broadcast" , {
1563
+ this . _sendPost ( ` ${ this . host } / ${ endpoint } ` , {
1543
1564
body : transactionString ,
1544
1565
headers : Object . assign ( { } , { ...this . headers , "X-ALEO-METHOD" : "submitTransaction" } , {
1545
1566
"Content-Type" : "application/json" ,
0 commit comments