@provablehq/sdk 0.10.0-rc → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/dynamic/browser.d.ts +8 -0
  2. package/dist/dynamic/browser.js +8 -0
  3. package/dist/dynamic/node.d.ts +8 -0
  4. package/dist/dynamic/node.js +8 -0
  5. package/dist/mainnet/account.d.ts +61 -6
  6. package/dist/mainnet/browser.d.ts +41 -8
  7. package/dist/mainnet/browser.js +3699 -564
  8. package/dist/mainnet/browser.js.map +1 -1
  9. package/dist/mainnet/constants.d.ts +6 -0
  10. package/dist/mainnet/external-signing.d.ts +76 -0
  11. package/dist/mainnet/integrations/sealance/merkle-tree.d.ts +192 -0
  12. package/dist/mainnet/keys/keystore/error.d.ts +24 -0
  13. package/dist/mainnet/keys/keystore/file.d.ts +177 -0
  14. package/dist/mainnet/keys/keystore/interface.d.ts +161 -0
  15. package/dist/mainnet/keys/provider/interface.d.ts +170 -0
  16. package/dist/mainnet/{function-key-provider.d.ts → keys/provider/memory.d.ts} +27 -167
  17. package/dist/mainnet/{offline-key-provider.d.ts → keys/provider/offline.d.ts} +21 -4
  18. package/dist/mainnet/keys/verifier/interface.d.ts +70 -0
  19. package/dist/mainnet/keys/verifier/memory.d.ts +37 -0
  20. package/dist/mainnet/models/cryptoBoxPubkey.d.ts +4 -0
  21. package/dist/mainnet/models/encryptedProvingRequest.d.ts +4 -0
  22. package/dist/mainnet/models/external-signing.d.ts +123 -0
  23. package/dist/mainnet/models/functionInput.d.ts +7 -0
  24. package/dist/mainnet/models/input/inputJSON.d.ts +1 -0
  25. package/dist/mainnet/models/input/inputObject.d.ts +1 -0
  26. package/dist/mainnet/models/keyPair.d.ts +4 -0
  27. package/dist/mainnet/models/output/outputJSON.d.ts +1 -0
  28. package/dist/mainnet/models/output/outputObject.d.ts +1 -0
  29. package/dist/mainnet/models/provingResponse.d.ts +48 -2
  30. package/dist/mainnet/models/record-provider/encryptedRecord.d.ts +58 -0
  31. package/dist/mainnet/models/record-provider/ownedRecord.d.ts +60 -0
  32. package/dist/mainnet/models/record-provider/recordSearchParams.d.ts +19 -0
  33. package/dist/mainnet/models/record-scanner/encryptedRecordsResult.d.ts +7 -0
  34. package/dist/mainnet/models/record-scanner/encryptedRegistrationRequest.d.ts +8 -0
  35. package/dist/mainnet/models/record-scanner/error.d.ts +47 -0
  36. package/dist/mainnet/models/record-scanner/ownedFilter.d.ts +22 -0
  37. package/dist/mainnet/models/record-scanner/ownedRecordsResponseFilter.d.ts +42 -0
  38. package/dist/mainnet/models/record-scanner/ownedRecordsResult.d.ts +13 -0
  39. package/dist/mainnet/models/record-scanner/recordsFilter.d.ts +35 -0
  40. package/dist/mainnet/models/record-scanner/recordsResponseFilter.d.ts +42 -0
  41. package/dist/mainnet/models/record-scanner/registrationRequest.d.ts +13 -0
  42. package/dist/mainnet/models/record-scanner/registrationResponse.d.ts +13 -0
  43. package/dist/mainnet/models/record-scanner/registrationResult.d.ts +9 -0
  44. package/dist/mainnet/models/record-scanner/revokeResult.d.ts +17 -0
  45. package/dist/mainnet/models/record-scanner/serialNumbersResult.d.ts +15 -0
  46. package/dist/mainnet/models/record-scanner/statusResponse.d.ts +13 -0
  47. package/dist/mainnet/models/record-scanner/statusResult.d.ts +13 -0
  48. package/dist/mainnet/models/record-scanner/tagsResult.d.ts +12 -0
  49. package/dist/mainnet/network-client.d.ts +129 -46
  50. package/dist/mainnet/node-polyfill.js +2 -49
  51. package/dist/mainnet/node-polyfill.js.map +1 -1
  52. package/dist/mainnet/node.d.ts +1 -0
  53. package/dist/mainnet/node.js +376 -4
  54. package/dist/mainnet/node.js.map +1 -1
  55. package/dist/mainnet/program-manager.d.ts +538 -58
  56. package/dist/mainnet/record-provider.d.ts +113 -75
  57. package/dist/mainnet/record-scanner.d.ts +368 -0
  58. package/dist/mainnet/security.d.ts +62 -0
  59. package/dist/mainnet/utils.d.ts +1 -0
  60. package/dist/mainnet/wasm.d.ts +1 -1
  61. package/dist/testnet/account.d.ts +61 -6
  62. package/dist/testnet/browser.d.ts +41 -8
  63. package/dist/testnet/browser.js +3699 -564
  64. package/dist/testnet/browser.js.map +1 -1
  65. package/dist/testnet/constants.d.ts +6 -0
  66. package/dist/testnet/external-signing.d.ts +76 -0
  67. package/dist/testnet/integrations/sealance/merkle-tree.d.ts +192 -0
  68. package/dist/testnet/keys/keystore/error.d.ts +24 -0
  69. package/dist/testnet/keys/keystore/file.d.ts +177 -0
  70. package/dist/testnet/keys/keystore/interface.d.ts +161 -0
  71. package/dist/testnet/keys/provider/interface.d.ts +170 -0
  72. package/dist/testnet/{function-key-provider.d.ts → keys/provider/memory.d.ts} +27 -167
  73. package/dist/testnet/{offline-key-provider.d.ts → keys/provider/offline.d.ts} +21 -4
  74. package/dist/testnet/keys/verifier/interface.d.ts +70 -0
  75. package/dist/testnet/keys/verifier/memory.d.ts +37 -0
  76. package/dist/testnet/models/cryptoBoxPubkey.d.ts +4 -0
  77. package/dist/testnet/models/encryptedProvingRequest.d.ts +4 -0
  78. package/dist/testnet/models/external-signing.d.ts +123 -0
  79. package/dist/testnet/models/functionInput.d.ts +7 -0
  80. package/dist/testnet/models/input/inputJSON.d.ts +1 -0
  81. package/dist/testnet/models/input/inputObject.d.ts +1 -0
  82. package/dist/testnet/models/keyPair.d.ts +4 -0
  83. package/dist/testnet/models/output/outputJSON.d.ts +1 -0
  84. package/dist/testnet/models/output/outputObject.d.ts +1 -0
  85. package/dist/testnet/models/provingResponse.d.ts +48 -2
  86. package/dist/testnet/models/record-provider/encryptedRecord.d.ts +58 -0
  87. package/dist/testnet/models/record-provider/ownedRecord.d.ts +60 -0
  88. package/dist/testnet/models/record-provider/recordSearchParams.d.ts +19 -0
  89. package/dist/testnet/models/record-scanner/encryptedRecordsResult.d.ts +7 -0
  90. package/dist/testnet/models/record-scanner/encryptedRegistrationRequest.d.ts +8 -0
  91. package/dist/testnet/models/record-scanner/error.d.ts +47 -0
  92. package/dist/testnet/models/record-scanner/ownedFilter.d.ts +22 -0
  93. package/dist/testnet/models/record-scanner/ownedRecordsResponseFilter.d.ts +42 -0
  94. package/dist/testnet/models/record-scanner/ownedRecordsResult.d.ts +13 -0
  95. package/dist/testnet/models/record-scanner/recordsFilter.d.ts +35 -0
  96. package/dist/testnet/models/record-scanner/recordsResponseFilter.d.ts +42 -0
  97. package/dist/testnet/models/record-scanner/registrationRequest.d.ts +13 -0
  98. package/dist/testnet/models/record-scanner/registrationResponse.d.ts +13 -0
  99. package/dist/testnet/models/record-scanner/registrationResult.d.ts +9 -0
  100. package/dist/testnet/models/record-scanner/revokeResult.d.ts +17 -0
  101. package/dist/testnet/models/record-scanner/serialNumbersResult.d.ts +15 -0
  102. package/dist/testnet/models/record-scanner/statusResponse.d.ts +13 -0
  103. package/dist/testnet/models/record-scanner/statusResult.d.ts +13 -0
  104. package/dist/testnet/models/record-scanner/tagsResult.d.ts +12 -0
  105. package/dist/testnet/network-client.d.ts +129 -46
  106. package/dist/testnet/node-polyfill.js +2 -49
  107. package/dist/testnet/node-polyfill.js.map +1 -1
  108. package/dist/testnet/node.d.ts +1 -0
  109. package/dist/testnet/node.js +376 -4
  110. package/dist/testnet/node.js.map +1 -1
  111. package/dist/testnet/program-manager.d.ts +538 -58
  112. package/dist/testnet/record-provider.d.ts +113 -75
  113. package/dist/testnet/record-scanner.d.ts +368 -0
  114. package/dist/testnet/security.d.ts +62 -0
  115. package/dist/testnet/utils.d.ts +1 -0
  116. package/dist/testnet/wasm.d.ts +1 -1
  117. package/package.json +11 -6
@@ -1,27 +1,50 @@
1
1
  import { Account } from "./account.js";
2
2
  import { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports } from "./network-client.js";
3
3
  import { ImportedPrograms, ImportedVerifyingKeys } from "./models/imports.js";
4
- import { RecordProvider, RecordSearchParams } from "./record-provider.js";
5
- import { FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider.js";
6
- import { Authorization, ExecutionResponse, OfflineQuery, RecordPlaintext, PrivateKey, Program, ProvingKey, ProvingRequest, VerifyingKey, Transaction } from "./wasm.js";
4
+ import { RecordProvider } from "./record-provider.js";
5
+ import { RecordSearchParams } from "./models/record-provider/recordSearchParams.js";
6
+ import { FunctionKeyProvider, KeySearchParams } from "./keys/provider/interface.js";
7
+ import { FunctionKeyPair } from "./models/keyPair.js";
8
+ import { Authorization, ExecutionRequest, ExecutionResponse, OfflineQuery, RecordPlaintext, PrivateKey, Program, ProvingKey, ProvingRequest, VerifyingKey, Transaction } from "./wasm.js";
9
+ import { ExternalSigningOptions } from "./models/external-signing.js";
10
+ /**
11
+ * Represents the options for deploying and upgrading a transaction in the Aleo network.
12
+ * This interface is used to specify the parameters required for building and submitting an deployment transaction.
13
+ *
14
+ * @property {string} program - The program source code to be deployed.
15
+ * @property {number} priorityFee - The priority fee to be paid for the transaction.
16
+ * @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.
17
+ * @property {RecordSearchParams} [recordSearchParams] - Parameters for searching for a record to pay the execution transaction fee.
18
+ * @property {string | RecordPlaintext} [feeRecord] - Fee record to use for the transaction.
19
+ * @property {PrivateKey} [privateKey] - Private key to use for the transaction.
20
+ */
21
+ interface DeployOptions {
22
+ program: string;
23
+ priorityFee: number;
24
+ privateFee: boolean;
25
+ recordSearchParams?: RecordSearchParams;
26
+ feeRecord?: string | RecordPlaintext;
27
+ privateKey?: PrivateKey;
28
+ }
7
29
  /**
8
30
  * Represents the options for executing a transaction in the Aleo network.
9
31
  * This interface is used to specify the parameters required for building and submitting an execution transaction.
10
32
  *
11
33
  * @property {string} programName - The name of the program containing the function to be executed.
12
34
  * @property {string} functionName - The name of the function to execute within the program.
13
- * @property {number} priorityFee - The optional priority fee to be paid for the transaction.
35
+ * @property {number} priorityFee - The priority fee to be paid for the transaction.
14
36
  * @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.
15
37
  * @property {string[]} inputs - The inputs to the function being executed.
16
- * @property {RecordSearchParams} [recordSearchParams] - Optional parameters for searching for a record to pay the execution transaction fee.
17
- * @property {KeySearchParams} [keySearchParams] - Optional parameters for finding the matching proving & verifying keys for the function.
18
- * @property {string | RecordPlaintext} [feeRecord] - Optional fee record to use for the transaction.
19
- * @property {ProvingKey} [provingKey] - Optional proving key to use for the transaction.
20
- * @property {VerifyingKey} [verifyingKey] - Optional verifying key to use for the transaction.
21
- * @property {PrivateKey} [privateKey] - Optional private key to use for the transaction.
22
- * @property {OfflineQuery} [offlineQuery] - Optional offline query if creating transactions in an offline environment.
23
- * @property {string | Program} [program] - Optional program source code to use for the transaction.
24
- * @property {ProgramImports} [imports] - Optional programs that the program being executed imports.
38
+ * @property {RecordSearchParams} [recordSearchParams] - Parameters for searching for a record to pay the execution transaction fee.
39
+ * @property {KeySearchParams} [keySearchParams] - Parameters for finding the matching proving & verifying keys for the function.
40
+ * @property {string | RecordPlaintext} [feeRecord] - Fee record to use for the transaction.
41
+ * @property {ProvingKey} [provingKey] - Proving key to use for the transaction.
42
+ * @property {VerifyingKey} [verifyingKey] - Verifying key to use for the transaction.
43
+ * @property {PrivateKey} [privateKey] - Private key to use for the transaction.
44
+ * @property {OfflineQuery} [offlineQuery] - Offline query if creating transactions in an offline environment.
45
+ * @property {string | Program} [program] - Program source code to use for the transaction.
46
+ * @property {ProgramImports} [imports] - Programs that the program being executed imports.
47
+ * @property {number} [edition] - Edition of the program to execute the function in.
25
48
  */
26
49
  interface ExecuteOptions {
27
50
  programName: string;
@@ -43,12 +66,13 @@ interface ExecuteOptions {
43
66
  /**
44
67
  * Options for building an Authorization for a function.
45
68
  *
46
- * @property programName {string} Name of the program containing the function to build the authorization for.
47
- * @property functionName {string} Name of the function name to build the authorization for.
48
- * @property inputs {string[]} The inputs to the function.
49
- * @property programSource {string | Program} The optional source code for the program to build an execution for.
50
- * @property privateKey {PrivateKey} Optional private key to use to build the authorization.
51
- * @property programImports {ProgramImports} The other programs the program imports.
69
+ * @property {string} programName Name of the program containing the function to build the authorization for.
70
+ * @property {string} functionName Name of the function name to build the authorization for.
71
+ * @property {string[]} inputs The inputs to the function.
72
+ * @property {string | Program} [programSource] The optional source code for the program to build an execution for.
73
+ * @property {PrivateKey} [privateKey] Optional private key to use to build the authorization.
74
+ * @property {ProgramImports} [programImports] The other programs the program imports.
75
+ * @property {edition} [edition]
52
76
  */
53
77
  interface AuthorizationOptions {
54
78
  programName: string;
@@ -62,11 +86,11 @@ interface AuthorizationOptions {
62
86
  /**
63
87
  * Options for executing a fee authorization.
64
88
  *
65
- * @property deploymentOrExecutionId {string} The id of a previously built Execution or Authorization.
66
- * @property baseFeeCredits {number} The number of Aleo Credits to pay for the base fee.
67
- * @property priorityFeeCredits {number} The number of Aleo Credits to pay for the priority fee.
68
- * @property privateKey {PrivateKey} Optional private key to specify for the authorization.
69
- * @property feeRecord {RecordPlaintext} A record to specify to pay the private fee. If this is specified a `fee_private` authorization will be built.
89
+ * @property {string} deploymentOrExecutionId The id of a previously built Execution or Authorization.
90
+ * @property {number} baseFeeCredits The number of Aleo Credits to pay for the base fee.
91
+ * @property {number} [priorityFeeCredits] The number of Aleo Credits to pay for the priority fee.
92
+ * @property {PrivateKey} [privateKey] Optional private key to specify for the authorization.
93
+ * @property {RecordPlaintext} [feeRecord] A record to specify to pay the private fee. If this is specified a `fee_private` authorization will be built.
70
94
  */
71
95
  interface FeeAuthorizationOptions {
72
96
  deploymentOrExecutionId: string;
@@ -75,13 +99,36 @@ interface FeeAuthorizationOptions {
75
99
  privateKey?: PrivateKey;
76
100
  feeRecord?: RecordPlaintext;
77
101
  }
102
+ /**
103
+ * Represents the options for executing a transaction on the Aleo Network from an authorization.
104
+ *
105
+ * @property {string} programName - The name of the program containing the function to be executed.
106
+ * @property {KeySearchParams} [keySearchParams] - Optional parameters for finding the matching proving & verifying keys for the function.
107
+ * @property {ProvingKey} [provingKey] - Optional proving key to use for the transaction.
108
+ * @property {VerifyingKey} [verifyingKey] - Optional verifying key to use for the transaction.
109
+ * @property {OfflineQuery} [offlineQuery] - Optional offline query if creating transactions in an offline environment.
110
+ * @property {string | Program} [program] - Optional program source code to use for the transaction.
111
+ * @property {ProgramImports} [imports] - Optional programs that the program being executed imports.
112
+ */
113
+ interface ExecuteAuthorizationOptions {
114
+ programName: string;
115
+ authorization: Authorization;
116
+ feeAuthorization?: Authorization;
117
+ keySearchParams?: KeySearchParams;
118
+ provingKey?: ProvingKey;
119
+ verifyingKey?: VerifyingKey;
120
+ offlineQuery?: OfflineQuery;
121
+ program?: string | Program;
122
+ imports?: ProgramImports;
123
+ }
78
124
  /**
79
125
  * Represents the options for executing a transaction in the Aleo network.
80
126
  * This interface is used to specify the parameters required for building and submitting an execution transaction.
81
127
  *
82
128
  * @property {string} programName - The name of the program containing the function to be executed.
83
129
  * @property {string} functionName - The name of the function to execute within the program.
84
- * @property {number} baseFee - The base fee to be paid for the transaction.
130
+ * @property {number} [baseFee] - The base fee to be paid for the transaction.
131
+ * @deprecated Base fee is now estimated automatically; this option is ignored and will be removed in a future version.
85
132
  * @property {number} priorityFee - The optional priority fee to be paid for the transaction.
86
133
  * @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.
87
134
  * @property {string[]} inputs - The inputs to the function being executed.
@@ -92,14 +139,17 @@ interface FeeAuthorizationOptions {
92
139
  * @property {string} uri - The URI send the ProvingRequest to.
93
140
  * @property {ProgramImports} [imports] - Optional programs that the program being executed imports.
94
141
  * @property {boolean} broadcast - Whether to broadcast the Transaction generated by the remove prover to the Aleo network.
142
+ * @property {boolean} unchecked - Whether to execute the transaction without checking the validity of the authorization (faster but may fail).
143
+ * @property {number} [edition] - Edition of the program to execute the function in.
144
+ * @property {boolean} [useFeeMaster] - Whether to use the FeeMaster account to execute the transaction.
95
145
  */
96
146
  interface ProvingRequestOptions {
97
147
  programName: string;
98
148
  functionName: string;
99
- baseFee: number;
100
149
  priorityFee: number;
101
150
  privateFee: boolean;
102
- inputs: string[];
151
+ inputs?: string[];
152
+ baseFee?: number;
103
153
  recordSearchParams?: RecordSearchParams;
104
154
  feeRecord?: string | RecordPlaintext;
105
155
  privateKey?: PrivateKey;
@@ -108,6 +158,50 @@ interface ProvingRequestOptions {
108
158
  broadcast?: boolean;
109
159
  unchecked?: boolean;
110
160
  edition?: number;
161
+ useFeeMaster?: boolean;
162
+ executionRequest?: ExecutionRequest;
163
+ }
164
+ /**
165
+ * Fee estimate options.
166
+ *
167
+ * @property {string} programName - The name of the program containing the function to estimate the fee for.
168
+ * @property {string} functionName - The name of the function to execute within the program to estimate the fee for.
169
+ * @property {string} [program] - Program source code to use for the fee estimate.
170
+ * @property {ProgramImports} [imports] - Programs that the program imports.
171
+ * @property {number} [edition] - Edition of the program to estimate the fee for.
172
+ * @property {Authorization} authorization - An authorization to estimate the fee for.
173
+ */
174
+ interface FeeEstimateOptions {
175
+ programName: string;
176
+ functionName?: string;
177
+ program?: string | Program;
178
+ imports?: ProgramImports;
179
+ edition?: number;
180
+ authorization?: Authorization;
181
+ }
182
+ /**
183
+ * Options for verifying a single Aleo zkSnark proof.
184
+ *
185
+ * @property {string} verifyingKey - The verifying key string for the circuit
186
+ * @property {string[]} inputs - Array of public input strings — either field elements (e.g. "1field") or Aleo types (e.g. "1u32", "{ x: 1u8 }")
187
+ * @property {string} proof - The proof string to verify
188
+ */
189
+ interface VerificationOptions {
190
+ verifyingKey: string;
191
+ inputs: string[];
192
+ proof: string;
193
+ }
194
+ /**
195
+ * Options for verifying a batch Aleo zkSnark proof.
196
+ *
197
+ * @property {string[]} verifyingKeys - Array of verifying key strings, one per circuit
198
+ * @property {string[][][]} inputs - 3D array of input strings [circuit_idx][instance_idx][input_idx]
199
+ * @property {string} proof - The batch proof string to verify
200
+ */
201
+ interface BatchVerificationOptions {
202
+ verifyingKeys: string[];
203
+ inputs: string[][][];
204
+ proof: string;
111
205
  }
112
206
  /**
113
207
  * The ProgramManager class is used to execute and deploy programs on the Aleo network and create value transfers.
@@ -118,6 +212,7 @@ declare class ProgramManager {
118
212
  host: string;
119
213
  networkClient: AleoNetworkClient;
120
214
  recordProvider: RecordProvider | undefined;
215
+ inclusionKeysLoaded: boolean;
121
216
  /** Create a new instance of the ProgramManager
122
217
  *
123
218
  * @param { string | undefined } host A host uri running the official Aleo API
@@ -163,12 +258,31 @@ declare class ProgramManager {
163
258
  * import { ProgramManager } from "@provablehq/sdk/mainnet.js";
164
259
  *
165
260
  * // Create a ProgramManager
166
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1");
261
+ * const programManager = new ProgramManager("https://api.provable.com/v2");
167
262
  *
168
263
  * // Set the value of the `Accept-Language` header to `en-US`
169
264
  * programManager.setHeader('Accept-Language', 'en-US');
170
265
  */
171
266
  setHeader(headerName: string, value: string): void;
267
+ /**
268
+ * Set the inclusion prover into the wasm memory. This should be done prior to any execution of a function with a
269
+ * private record.
270
+ *
271
+ * @param {ProvingKey} [provingKey]
272
+ *
273
+ * @example
274
+ * import { ProgramManager, AleoKeyProvider } from "@provablehq/sdk/mainnet.js";
275
+ *
276
+ * const keyProvider = new AleoKeyProvider();
277
+ * keyProvider.useCache(true);
278
+ *
279
+ * // Create a ProgramManager
280
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider);
281
+ *
282
+ * // Set the inclusion keys.
283
+ * programManager.setInclusionProver();
284
+ */
285
+ setInclusionProver(provingKey?: ProvingKey): Promise<void>;
172
286
  /**
173
287
  * Remove a header from the `AleoNetworkClient`s header map
174
288
  *
@@ -178,7 +292,7 @@ declare class ProgramManager {
178
292
  * import { ProgramManager } from "@provablehq/sdk/mainnet.js";
179
293
  *
180
294
  * // Create a ProgramManager
181
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1");
295
+ * const programManager = new ProgramManager("https://api.provable.com/v2");
182
296
  *
183
297
  * // Remove the default `X-Aleo-SDK-Version` header
184
298
  * programManager.removeHeader('X-Aleo-SDK-Version');
@@ -206,7 +320,7 @@ declare class ProgramManager {
206
320
  *
207
321
  * // Initialize a program manager with the key provider to automatically fetch keys for deployments
208
322
  * const program = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n";
209
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
323
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
210
324
  * programManager.setAccount(Account);
211
325
  *
212
326
  * // Define a fee in credits
@@ -223,6 +337,39 @@ declare class ProgramManager {
223
337
  * }, 20000);
224
338
  */
225
339
  buildDeploymentTransaction(program: string, priorityFee: number, privateFee: boolean, recordSearchParams?: RecordSearchParams, feeRecord?: string | RecordPlaintext, privateKey?: PrivateKey): Promise<Transaction>;
340
+ /**
341
+ * Builds a deployment transaction for submission to the Aleo network that upgrades an existing program.
342
+ *
343
+ * @param {DeployOptions} options The deployment options.
344
+ *
345
+ * @example
346
+ * /// Import the mainnet version of the sdk.
347
+ * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
348
+ *
349
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider
350
+ * const keyProvider = new AleoKeyProvider();
351
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
352
+ * keyProvider.useCache(true);
353
+ *
354
+ * // Initialize a program manager with the key provider to automatically fetch keys for deployments
355
+ * const program = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n";
356
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
357
+ * programManager.setAccount(Account);
358
+ *
359
+ * // Define a fee in credits
360
+ * const priorityFee = 0.0;
361
+ *
362
+ * // Create the deployment transaction.
363
+ * const tx = await programManager.buildUpgradeTransaction({program: program, priorityFee: fee, privateFee: false});
364
+ * await programManager.networkClient.submitTransaction(tx);
365
+ *
366
+ * // Verify the transaction was successful
367
+ * setTimeout(async () => {
368
+ * const transaction = await programManager.networkClient.getTransaction(tx.id());
369
+ * assert(transaction.id() === tx.id());
370
+ * }, 20000);
371
+ */
372
+ buildUpgradeTransaction(options: DeployOptions): Promise<Transaction>;
226
373
  /**
227
374
  * Deploy an Aleo program to the Aleo network
228
375
  *
@@ -245,7 +392,7 @@ declare class ProgramManager {
245
392
  *
246
393
  * // Initialize a program manager with the key provider to automatically fetch keys for deployments
247
394
  * const program = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n";
248
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
395
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
249
396
  *
250
397
  * // Define a fee in credits
251
398
  * const priorityFee = 0.0;
@@ -276,7 +423,7 @@ declare class ProgramManager {
276
423
  * keyProvider.useCache(true);
277
424
  *
278
425
  * // Initialize a program manager with the key provider to automatically fetch keys for executions
279
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
426
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
280
427
  *
281
428
  * // Build and execute the transaction
282
429
  * const tx = await programManager.buildExecutionTransaction({
@@ -298,6 +445,77 @@ declare class ProgramManager {
298
445
  * }, 10000);
299
446
  */
300
447
  buildExecutionTransaction(options: ExecuteOptions): Promise<Transaction>;
448
+ /**
449
+ * Builds an execution transaction for submission to the Aleo network from an Authorization and Fee Authorization.
450
+ * This method is helpful if signing and authorization needs to be done in a secure environment separate from where
451
+ * transactions are built.
452
+ *
453
+ * @param {ExecuteAuthorizationOptions} options - The options for executing the authorizations.
454
+ * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.
455
+ *
456
+ * @example
457
+ * import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from "@provablehq/sdk";
458
+ *
459
+ * await initThreadPool();
460
+ *
461
+ * // Create a new KeyProvider.
462
+ * const keyProvider = new AleoKeyProvider();
463
+ * keyProvider.useCache(true);
464
+ *
465
+ * // Initialize a program manager with the key provider to automatically fetch keys for executions.
466
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider);
467
+ *
468
+ * // Build the `Authorization`.
469
+ * const privateKey = new PrivateKey(); // Change this to a private key that has an aleo credit balance.
470
+ * const authorization = await programManager.buildAuthorization({
471
+ * programName: "credits.aleo",
472
+ * functionName: "transfer_public",
473
+ * privateKey,
474
+ * inputs: [
475
+ * "aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
476
+ * "10000000u64",
477
+ * ],
478
+ * });
479
+ *
480
+ * console.log("Getting execution id");
481
+ *
482
+ * // Derive the execution ID and base fee.
483
+ * const executionId = authorization.toExecutionId().toString();
484
+ *
485
+ * console.log("Estimating fee");
486
+ *
487
+ * // Get the base fee in microcredits.
488
+ * const baseFeeMicrocredits = await programManager.estimateFeeForAuthorization(authorization, "credits.aleo");
489
+ * const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;
490
+ *
491
+ * console.log("Building fee authorization");
492
+ *
493
+ * // Build a credits.aleo/fee_public `Authorization`.
494
+ * const feeAuthorization = await programManager.buildFeeAuthorization({
495
+ * deploymentOrExecutionId: executionId,
496
+ * baseFeeCredits,
497
+ * privateKey
498
+ * });
499
+ *
500
+ * console.log("Executing authorizations");
501
+ *
502
+ * // Build and execute the transaction.
503
+ * const tx = await programManager.buildTransactionFromAuthorization({
504
+ * programName: "credits.aleo",
505
+ * authorization,
506
+ * feeAuthorization,
507
+ * });
508
+ *
509
+ * // Submit the transaction to the network.
510
+ * await programManager.networkClient.submitTransaction(tx.toString());
511
+ *
512
+ * // Verify the transaction was successful.
513
+ * setTimeout(async () => {
514
+ * const transaction = await programManager.networkClient.getTransaction(tx.id());
515
+ * console.log(transaction);
516
+ * }, 10000);
517
+ */
518
+ buildTransactionFromAuthorization(options: ExecuteAuthorizationOptions): Promise<Transaction>;
301
519
  /**
302
520
  * Builds a SnarkVM `Authorization` for a specific function.
303
521
  *
@@ -314,7 +532,7 @@ declare class ProgramManager {
314
532
  * keyProvider.useCache(true);
315
533
  *
316
534
  * // Initialize a ProgramManager with the key and record providers.
317
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
535
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
318
536
  *
319
537
  * // Build the `Authorization`.
320
538
  * const authorization = await programManager.buildAuthorization({
@@ -343,7 +561,7 @@ declare class ProgramManager {
343
561
  * keyProvider.useCache(true);
344
562
  *
345
563
  * // Initialize a ProgramManager with the key and record providers.
346
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
564
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
347
565
  *
348
566
  * // Build the unchecked `Authorization`.
349
567
  * const authorization = await programManager.buildAuthorizationUnchecked({
@@ -357,7 +575,7 @@ declare class ProgramManager {
357
575
  */
358
576
  buildAuthorizationUnchecked(options: AuthorizationOptions): Promise<Authorization>;
359
577
  /**
360
- * Builds a `ProvingRequest` for submission to a prover for execution.
578
+ * Builds a `ProvingRequest` for submission to a prover for execution. If building a proving request with an ExecutionRequest, a private key must be explicitly provided.
361
579
  *
362
580
  * @param {ProvingRequestOptions} options - The options for building the proving request
363
581
  * @returns {Promise<ProvingRequest>} - A promise that resolves to the transaction or an error.
@@ -372,13 +590,12 @@ declare class ProgramManager {
372
590
  * keyProvider.useCache(true);
373
591
  *
374
592
  * // Initialize a ProgramManager with the key and record providers.
375
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
593
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
376
594
  *
377
595
  * // Build the proving request.
378
596
  * const provingRequest = await programManager.provingRequest({
379
597
  * programName: "credits.aleo",
380
598
  * functionName: "transfer_public",
381
- * baseFee: 100000,
382
599
  * priorityFee: 0,
383
600
  * privateFee: false,
384
601
  * inputs: [
@@ -405,17 +622,17 @@ declare class ProgramManager {
405
622
  * keyProvider.useCache(true);
406
623
  *
407
624
  * // Initialize a ProgramManager with the key and record providers.
408
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
625
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
409
626
  *
410
627
  * // Build a credits.aleo/fee_public `Authorization`.
411
- * const feePublicAuthorization = await programManager.authorizeFee({
628
+ * const feePublicAuthorization = await programManager.buildFeeAuthorization({
412
629
  * deploymentOrExecutionId: "2423957656946557501636078245035919227529640894159332581642187482178647335171field",
413
630
  * baseFeeCredits: 0.1,
414
631
  * });
415
632
  *
416
633
  * // Build a credits.aleo/fee_private `Authorization`.
417
634
  * const record = "{ owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private, microcredits: 1500000000000000u64.private, _nonce: 3077450429259593211617823051143573281856129402760267155982965992208217472983group.public }";
418
- * const feePrivateAuthorization = await programManager.authorizeFee({
635
+ * const feePrivateAuthorization = await programManager.buildFeeAuthorization({
419
636
  * deploymentOrExecutionId: "2423957656946557501636078245035919227529640894159332581642187482178647335171field",
420
637
  * baseFeeCredits: 0.1,
421
638
  * feeRecord: record,
@@ -438,7 +655,7 @@ declare class ProgramManager {
438
655
  * keyProvider.useCache(true);
439
656
  *
440
657
  * // Initialize a program manager with the key provider to automatically fetch keys for executions
441
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
658
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
442
659
  *
443
660
  * // Build and execute the transaction
444
661
  * const tx_id = await programManager.execute({
@@ -513,7 +730,7 @@ declare class ProgramManager {
513
730
  * keyProvider.useCache(true);
514
731
  *
515
732
  * // Initialize a program manager with the key provider to automatically fetch keys for executions
516
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
733
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
517
734
  * const record_1 = "{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}"
518
735
  * const record_2 = "{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 1540945439182663264862696551825005342995406165131907382295858612069623286213group.public}"
519
736
  * const tx_id = await programManager.join(record_1, record_2, 0.05, false);
@@ -544,7 +761,7 @@ declare class ProgramManager {
544
761
  * keyProvider.useCache(true);
545
762
  *
546
763
  * // Initialize a program manager with the key provider to automatically fetch keys for executions
547
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
764
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
548
765
  * const record = "{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}"
549
766
  * const tx_id = await programManager.split(25000000, record);
550
767
  *
@@ -591,7 +808,7 @@ declare class ProgramManager {
591
808
  * keyProvider.useCache(true);
592
809
  *
593
810
  * // Initialize a program manager with the key provider to automatically fetch keys for executions
594
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
811
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
595
812
  * const tx = await programManager.buildTransferTransaction(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "public", 0.2, false);
596
813
  * await programManager.networkClient.submitTransaction(tx.toString());
597
814
  *
@@ -622,7 +839,7 @@ declare class ProgramManager {
622
839
  * keyProvider.useCache(true);
623
840
  *
624
841
  * // Initialize a program manager with the key provider to automatically fetch keys for executions
625
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
842
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
626
843
  * const tx = await programManager.buildTransferPublicTransaction(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", 0.2);
627
844
  * await programManager.networkClient.submitTransaction(tx.toString());
628
845
  *
@@ -653,7 +870,7 @@ declare class ProgramManager {
653
870
  * keyProvider.useCache(true);
654
871
  *
655
872
  * // Initialize a program manager with the key provider to automatically fetch keys for executions
656
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
873
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
657
874
  * const tx = await programManager.buildTransferPublicAsSignerTransaction(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", 0.2);
658
875
  * await programManager.networkClient.submitTransaction(tx.toString());
659
876
  *
@@ -689,7 +906,7 @@ declare class ProgramManager {
689
906
  * keyProvider.useCache(true);
690
907
  *
691
908
  * // Initialize a program manager with the key provider to automatically fetch keys for executions
692
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
909
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
693
910
  * const tx_id = await programManager.transfer(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "public", 0.2, false);
694
911
  *
695
912
  * // Verify the transaction was successful
@@ -717,7 +934,7 @@ declare class ProgramManager {
717
934
  * keyProvider.useCache(true);
718
935
  *
719
936
  * // Create a new ProgramManager with the key that will be used to bond credits
720
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
937
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
721
938
  * programManager.setAccount(new Account("YourPrivateKey"));
722
939
  *
723
940
  * // Create the bonding transaction object for later submission
@@ -751,7 +968,7 @@ declare class ProgramManager {
751
968
  * keyProvider.useCache(true);
752
969
  *
753
970
  * // Create a new ProgramManager with the key that will be used to bond credits
754
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
971
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
755
972
  *
756
973
  * // Create the bonding transaction
757
974
  * tx_id = await programManager.bondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
@@ -782,7 +999,7 @@ declare class ProgramManager {
782
999
  * keyProvider.useCache(true);
783
1000
  *
784
1001
  * // Create a new ProgramManager with the key that will be used to bond credits
785
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
1002
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
786
1003
  * programManager.setAccount(new Account("YourPrivateKey"));
787
1004
  *
788
1005
  * // Create the bond validator transaction object for later use.
@@ -817,7 +1034,7 @@ declare class ProgramManager {
817
1034
  * keyProvider.useCache(true);
818
1035
  *
819
1036
  * // Create a new ProgramManager with the key that will be used to bond credits
820
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
1037
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
821
1038
  * programManager.setAccount(new Account("YourPrivateKey"));
822
1039
  *
823
1040
  * // Create the bonding transaction
@@ -847,7 +1064,7 @@ declare class ProgramManager {
847
1064
  * keyProvider.useCache(true);
848
1065
  *
849
1066
  * // Create a new ProgramManager with the key that will be used to unbond credits.
850
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
1067
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
851
1068
  * const tx = await programManager.buildUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", 2000000);
852
1069
  *
853
1070
  * // The transaction can be submitted later to the network using the network client.
@@ -882,7 +1099,7 @@ declare class ProgramManager {
882
1099
  * keyProvider.useCache(true);
883
1100
  *
884
1101
  * // Create a new ProgramManager with the key that will be used to bond credits
885
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
1102
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
886
1103
  * programManager.setAccount(new Account("YourPrivateKey"));
887
1104
  *
888
1105
  * // Create the unbond_public transaction and send it to the network
@@ -911,7 +1128,7 @@ declare class ProgramManager {
911
1128
  * keyProvider.useCache(true);
912
1129
  *
913
1130
  * // Create a new ProgramManager with the key that will be used to claim unbonded credits.
914
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
1131
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
915
1132
  *
916
1133
  * // Create the claim_unbond_public transaction object for later use.
917
1134
  * const tx = await programManager.buildClaimUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j");
@@ -943,7 +1160,7 @@ declare class ProgramManager {
943
1160
  * keyProvider.useCache(true);
944
1161
  *
945
1162
  * // Create a new ProgramManager with the key that will be used to bond credits
946
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
1163
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
947
1164
  * programManager.setAccount(new Account("YourPrivateKey"));
948
1165
  *
949
1166
  * // Create the claim_unbond_public transaction
@@ -980,7 +1197,7 @@ declare class ProgramManager {
980
1197
  * keyProvider.useCache(true);
981
1198
  *
982
1199
  * // Create a new ProgramManager with the key that will be used to bond credits
983
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
1200
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
984
1201
  *
985
1202
  * // Create the set_validator_state transaction
986
1203
  * const tx = await programManager.buildSetValidatorStateTransaction(true);
@@ -1019,7 +1236,7 @@ declare class ProgramManager {
1019
1236
  * keyProvider.useCache(true);
1020
1237
  *
1021
1238
  * // Create a new ProgramManager with the key that will be used to bond credits
1022
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
1239
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
1023
1240
  *
1024
1241
  * // Create the set_validator_state transaction
1025
1242
  * const tx_id = await programManager.setValidatorState(true);
@@ -1085,6 +1302,269 @@ declare class ProgramManager {
1085
1302
  * @param {string} program The program source code
1086
1303
  */
1087
1304
  verifyProgram(program: string): boolean;
1305
+ /**
1306
+ * Estimate the execution fee for an authorization.
1307
+ *
1308
+ * @param {FeeEstimateOptions} options Options for fee estimate.
1309
+ *
1310
+ * @example
1311
+ * import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from "@provablehq/sdk";
1312
+ *
1313
+ * await initThreadPool();
1314
+ *
1315
+ * // Create a new KeyProvider.
1316
+ * const keyProvider = new AleoKeyProvider();
1317
+ * keyProvider.useCache(true);
1318
+ *
1319
+ * // Initialize a program manager with the key provider to automatically fetch keys for executions.
1320
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider);
1321
+ *
1322
+ * // Build the `Authorization`.
1323
+ * const privateKey = new PrivateKey(); // Change this to a private key that has an aleo credit balance.
1324
+ * const authorization = await programManager.buildAuthorization({
1325
+ * programName: "credits.aleo",
1326
+ * functionName: "transfer_public",
1327
+ * privateKey,
1328
+ * inputs: [
1329
+ * "aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
1330
+ * "10000000u64",
1331
+ * ],
1332
+ * });
1333
+ *
1334
+ * console.log("Getting execution id");
1335
+ *
1336
+ * // Derive the execution ID and base fee.
1337
+ * const executionId = authorization.toExecutionId().toString();
1338
+ *
1339
+ * console.log("Estimating fee");
1340
+ *
1341
+ * // Get the base fee in microcredits.
1342
+ * const baseFeeMicrocredits = await programManager.estimateFeeForAuthorization({
1343
+ * authorization,
1344
+ * programName: "credits.aleo"
1345
+ * });
1346
+ * const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;
1347
+ *
1348
+ * console.log("Building fee authorization");
1349
+ *
1350
+ * // Build a credits.aleo/fee_public `Authorization`.
1351
+ * const feeAuthorization = await programManager.buildFeeAuthorization({
1352
+ * deploymentOrExecutionId: executionId,
1353
+ * baseFeeCredits,
1354
+ * privateKey
1355
+ * });
1356
+ */
1357
+ estimateFeeForAuthorization(options: FeeEstimateOptions): Promise<bigint>;
1358
+ /**
1359
+ * Estimate the execution fee for an Aleo function.
1360
+ *
1361
+ * @param {FeeEstimateOptions} options Options for the fee estimate.
1362
+ *
1363
+ * @returns {Promise<bigint>} Execution fee in microcredits for the authorization.
1364
+ *
1365
+ * @example
1366
+ * import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from "@provablehq/sdk";
1367
+ *
1368
+ * // Initialize a program manager with the key provider to automatically fetch keys for executions.
1369
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider);
1370
+ *
1371
+ * // Get the base fee in microcredits.
1372
+ * const baseFeeMicrocredits = await programManager.estimateExecutionFee({programName: "credits.aleo"});
1373
+ * const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;
1374
+ *
1375
+ * console.log("Building fee authorization");
1376
+ *
1377
+ * // Build a credits.aleo/fee_public `Authorization`.
1378
+ * const baseFeeMicrocredits = await programManager.estimateFeeForAuthorization({
1379
+ * programName: "credits.aleo",
1380
+ * functionName: "transfer_public",
1381
+ * });
1382
+ * const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;
1383
+ */
1384
+ estimateExecutionFee(options: FeeEstimateOptions): Promise<bigint>;
1088
1385
  getCreditsRecord(amount: number, nonces: string[], record?: RecordPlaintext | string, params?: RecordSearchParams): Promise<RecordPlaintext>;
1386
+ /**
1387
+ * Builds an execution transaction for submission to the a local devnode.
1388
+ * This method skips proof generation and is not meant for use with the mainnet or testnet Aleo networks.
1389
+ * Note: getOrInitConsensusVersionTestHeights must be called prior to using this method for this method to work properly.
1390
+ *
1391
+ * @param {ExecuteOptions} options - The options for the execution transaction.
1392
+ * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.
1393
+ *
1394
+ * @example
1395
+ * /// Import the mainnet version of the sdk.
1396
+ * import { AleoKeyProvider, getOrInitConsensusVersionTestHeights, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
1397
+ *
1398
+ * // Initialize the development consensus heights in order to work with devnode.
1399
+ * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12");
1400
+ *
1401
+ * // Create a new NetworkClient and RecordProvider.
1402
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
1403
+ * keyProvider.useCache(true);
1404
+ *
1405
+ * // Initialize a program manager.
1406
+ * const programManager = new ProgramManager("http://localhost:3030", recordProvider);
1407
+ *
1408
+ * // Build and execute the transaction.
1409
+ * const tx = await programManager.buildDevnodeExecutionTransaction({
1410
+ * programName: "hello_hello.aleo",
1411
+ * functionName: "hello_hello",
1412
+ * priorityFee: 0.0,
1413
+ * privateFee: false,
1414
+ * inputs: ["5u32", "5u32"],
1415
+ * });
1416
+ *
1417
+ * // Submit the transaction to the network
1418
+ * await programManager.networkClient.submitTransaction(tx.toString());
1419
+ *
1420
+ * // Verify the transaction was successful
1421
+ * setTimeout(async () => {
1422
+ * const transaction = await programManager.networkClient.getTransaction(tx.id());
1423
+ * assert(transaction.id() === tx.id());
1424
+ * }, 10000);
1425
+ */
1426
+ buildDevnodeExecutionTransaction(options: ExecuteOptions): Promise<Transaction>;
1427
+ /**
1428
+ * Builds a deployment transaction with placeholder certificates and verifying keys for each function in the program.
1429
+ * Intended for use with a local devnode.
1430
+ * `getOrInitConsensusVersionTestHeights` must be called with development heights prior to invoking this method for it to work properly.
1431
+ *
1432
+ * @param {DeployOptions} options - The options for the deployment transaction.
1433
+ * @returns {string} The transaction id of the deployed program or a failure message from the network
1434
+ *
1435
+ * @example
1436
+ * /// Import the mainnet version of the sdk.
1437
+ * import { ProgramManager, NetworkRecordProvider, getOrInitConsensusVersionTestHeights } from "@provablehq/sdk/mainnet.js";
1438
+ *
1439
+ * // Initialize the development consensus heights in order to work with a local devnode.
1440
+ * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12");
1441
+ *
1442
+ * // Create a new NetworkClient, and RecordProvider
1443
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
1444
+ * keyProvider.useCache(true);
1445
+ *
1446
+ * // Initialize a program manager with the key provider to automatically fetch keys for deployments
1447
+ * const program = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n";
1448
+ * const programManager = new ProgramManager("http://localhost:3030", recordProvider);
1449
+ * programManager.setAccount(Account);
1450
+ *
1451
+ * // Define a fee in credits
1452
+ * const priorityFee = 0.0;
1453
+ *
1454
+ * // Create the deployment transaction.
1455
+ * const tx = await programManager.buildDevnodeDeploymentTransaction({program: program, fee: priorityFee, privateFee: false});
1456
+ * await programManager.networkClient.submitTransaction(tx);
1457
+ *
1458
+ * // Verify the transaction was successful
1459
+ * setTimeout(async () => {
1460
+ * const transaction = await programManager.networkClient.getTransaction(tx.id());
1461
+ * assert(transaction.id() === tx.id());
1462
+ * }, 20000);
1463
+ */
1464
+ buildDevnodeDeploymentTransaction(options: DeployOptions): Promise<Transaction>;
1465
+ /**
1466
+ * Builds an upgrade transaction on a local devnodewith placeholder certificates and verifying keys for each function in the program.
1467
+ * This method is only intended for use with a local devnode.
1468
+ *
1469
+ * @param {DeployOptions} options - The options for the deployment transaction.
1470
+ * @returns {string} The transaction id of the deployed program or a failure message from the network
1471
+ *
1472
+ * @example
1473
+ * /// Import the mainnet version of the sdk.
1474
+ * import { ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
1475
+ *
1476
+ * // Create a new NetworkClient, and RecordProvider
1477
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
1478
+ * keyProvider.useCache(true);
1479
+ *
1480
+ * // Initialize a program manager with the key provider to automatically fetch keys for deployments
1481
+ * const program = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n";
1482
+ * const programManager = new ProgramManager("http://localhost:3030", recordProvider);
1483
+ * programManager.setAccount(Account);
1484
+ *
1485
+ * // Define a fee in credits
1486
+ * const priorityFee = 0.0;
1487
+ *
1488
+ * // Create the deployment transaction.
1489
+ * const tx = await programManager.buildDevnodeUpgradeTransaction({program: program, fee: priorityFee, privateFee: false});
1490
+ * await programManager.networkClient.submitTransaction(tx);
1491
+ *
1492
+ * // Verify the transaction was successful
1493
+ * setTimeout(async () => {
1494
+ * const transaction = await programManager.networkClient.getTransaction(tx.id());
1495
+ * assert(transaction.id() === tx.id());
1496
+ * }, 20000);
1497
+ */
1498
+ buildDevnodeUpgradeTransaction(options: DeployOptions): Promise<Transaction>;
1089
1499
  }
1090
- export { ProgramManager, AuthorizationOptions, FeeAuthorizationOptions, ExecuteOptions, ProvingRequestOptions };
1500
+ /**
1501
+ * Convert an array of Aleo type strings to field element strings.
1502
+ *
1503
+ * Inputs that are already field elements (e.g. "1field") are passed through directly.
1504
+ * Other Aleo values (e.g. "1u32", records, futures, dynamic records) are parsed via
1505
+ * Value and converted to their field representation.
1506
+ *
1507
+ * @param {string[]} inputs Array of Aleo value strings
1508
+ * @returns {string[]} Array of field element strings
1509
+ */
1510
+ declare function inputsToFields(inputs: string[]): string[];
1511
+ /**
1512
+ * Verify an Aleo zkSnark proof against a verifying key and public inputs.
1513
+ *
1514
+ * This verifies a proof produced by an Aleo program that may not be deployed on chain.
1515
+ * It directly invokes the Varuna proof verification from snarkVM.
1516
+ *
1517
+ * **Note:** The proof must have been generated with the Fiat-Shamir domain separator
1518
+ * "snark_verify". Proofs generated via snarkVM with a different function name will fail
1519
+ * verification even if the circuit and inputs are correct.
1520
+ *
1521
+ * Inputs can be raw field element strings (e.g. "1field") or Aleo type strings
1522
+ * (e.g. "1u32", "true", "{ x: 1u8, y: 2u8 }"). Non-field inputs are automatically
1523
+ * converted to their field representation via Value.toFields().
1524
+ *
1525
+ * @param {VerificationOptions} options The verification parameters
1526
+ * @returns {boolean} True if the proof is valid, false otherwise
1527
+ *
1528
+ * @example
1529
+ * import { verifyProof } from "@provablehq/sdk/mainnet.js";
1530
+ *
1531
+ * // Using raw field elements:
1532
+ * const isValid = verifyProof({
1533
+ * verifyingKey: "verifier1...",
1534
+ * inputs: ["1field", "2field"],
1535
+ * proof: "proof1...",
1536
+ * });
1537
+ *
1538
+ * // Using Aleo types (automatically converted to fields):
1539
+ * const isValid2 = verifyProof({
1540
+ * verifyingKey: "verifier1...",
1541
+ * inputs: ["1u32", "2u32"],
1542
+ * proof: "proof1...",
1543
+ * });
1544
+ */
1545
+ declare function verifyProof(options: VerificationOptions): boolean;
1546
+ /**
1547
+ * Verify a batch Aleo zkSnark proof against multiple verifying keys and their corresponding public inputs.
1548
+ *
1549
+ * Each verifying key is paired with one or more sets of public inputs (instances).
1550
+ * Inputs can be raw field element strings or Aleo type strings — non-field inputs
1551
+ * are automatically converted to their field representation.
1552
+ *
1553
+ * **Note:** The proof must have been generated with the Fiat-Shamir domain separator
1554
+ * "snark_verify_batch". Proofs generated with a different function name will fail
1555
+ * verification even if the circuits and inputs are correct.
1556
+ *
1557
+ * @param {BatchVerificationOptions} options The batch verification parameters
1558
+ * @returns {boolean} True if the batch proof is valid, false otherwise
1559
+ *
1560
+ * @example
1561
+ * import { verifyBatchProof } from "@provablehq/sdk/mainnet.js";
1562
+ *
1563
+ * const isValid = verifyBatchProof({
1564
+ * verifyingKeys: ["verifier1...", "verifier2..."],
1565
+ * inputs: [[["1field", "2field"]], [["3field"]]],
1566
+ * proof: "proof1...",
1567
+ * });
1568
+ */
1569
+ declare function verifyBatchProof(options: BatchVerificationOptions): boolean;
1570
+ export { ProgramManager, AuthorizationOptions, FeeAuthorizationOptions, ExecuteOptions, ProvingRequestOptions, ExternalSigningOptions, VerificationOptions, BatchVerificationOptions, inputsToFields, verifyProof, verifyBatchProof };